Note that there are some explanatory texts on larger screens.

plurals
  1. POCore Data: NSCocoaErrorDomain=134040 Only Occurs On Real Phone, Not Simulator
    primarykey
    data
    text
    <p>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 only occurs on the real iPhone in debug mode, not on the simulator. Any idea why this occurs?</p> <p>This is how I initially create my data store in the documents directory.</p> <pre><code> NSString *documentDirPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; NSURL *userDataStoreURL = [NSURL fileURLWithPath:[documentDirPath stringByAppendingPathComponent:@"userdata.coredata"]]; userDataStore= [persistentStoreCoordinator_ addPersistentStoreWithType:NSBinaryStoreType configuration:@"UserData" URL:userDataStoreURL options:nil error:&amp;error]; NSFileManager *fileManager = [NSFileManager defaultManager]; # The following IF statement never executes, so I know the file is being created. if(![fileManager fileExistsAtPath:[userDataStoreURL path]]) { NSLog(@"User data file does not exist: %@", [userDataStoreURL path]); } </code></pre> <p>This is how I save the context:</p> <pre><code>[managedObjectContext_ save:&amp;error]; </code></pre> <p>This is the error I get when trying to save the managed object context:</p> <pre><code>Error Domain=NSCocoaErrorDomain Code=134040 "The operation couldn’t be completed. (Cocoa error 134040.)" UserInfo=0x607b80 {NSAffectedStoresErrorKey=(    "&lt;NSBinaryObjectStore: 0x23f870&gt;",        (        "&lt;NSBinaryObjectStore: 0x23f870&gt;"    ) ), NSUnderlyingException=Save partially failed: Directory does not exist or is not writable /var/mobile/Applications/...[app bundle path]} </code></pre> <p><strong>MORE CLARIFICATION</strong></p> <p>I actually have 2 persistent stores. One is suppose to be read only data that doesn't change in between upgrades and it resides in the main bundle. The other is a data store for things saved by the user, and this resides inside the Document folder. Both persistent stores belong to the same managed object context, but I use configurations to only save certain entities to each (i.e. read only entities go in one, user saved entities goes in another).</p> <pre><code>NSPersistentStore *readonlyStore = [persistentStoreCoordinator_ addPersistentStoreWithType:NSBinaryStoreType configuration:@"ReadOnlyData" URL:readonlyStoreURL options:nil error:&amp;error]; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload