Core Data: NSCocoaErrorDomain=134040 Only Occurs On Real Phone, Not Simulator

前端 未结 1 791
梦谈多话
梦谈多话 2021-01-23 17:31

I\'m using Core Data to save a persistent store in the document directory of my application. When I attempt to save my managed context changes, I get a Cocoa Error 134040. This

1条回答
  •  孤城傲影
    2021-01-23 18:05

    When you get an error, look it up. This one is in CoreDataErrors.h (there are also FoundationErrors.h and a few others):

        NSPersistentStoreIncompleteSaveError             = 134040, // one or more of the stores returned an error during save (stores/objects that failed will be in userInfo)
    

    So, you couldn't save, and the userInfo tells you why.

    Indeed it does. From your question:

    NSUnderlyingException=Save partially failed: Directory does not exist or is not writable /var/mobile/Applications/...[app bundle path]}
    

    You're trying to save into your app bundle. That won't work; your app bundle is not writable (certainly not on the device).

    You showed the creation of a persistent store in the documents directory. As far as I can tell by reading it, that should be working. Do you have any other persistent stores, perhaps that you intended to default to the contents of/migrate from? If so, please edit your question to include that code.

    0 讨论(0)
提交回复
热议问题