Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6365681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:19:27+00:00 2026-05-25T00:19:27+00:00

I’m using Core Data to save a persistent store in the document directory of

  • 0

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?

This is how I initially create my data store in the documents directory.

    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:&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]);
    }

This is how I save the context:

[managedObjectContext_ save:&error];

This is the error I get when trying to save the managed object context:

Error Domain=NSCocoaErrorDomain Code=134040 "The operation couldn’t be completed. (Cocoa error 134040.)" UserInfo=0x607b80 {NSAffectedStoresErrorKey=(
    "<NSBinaryObjectStore: 0x23f870>",
        (
        "<NSBinaryObjectStore: 0x23f870>"
    )
), NSUnderlyingException=Save partially failed: Directory does not exist or is not writable /var/mobile/Applications/...[app bundle path]}

MORE CLARIFICATION

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).

NSPersistentStore *readonlyStore = [persistentStoreCoordinator_
  addPersistentStoreWithType:NSBinaryStoreType
  configuration:@"ReadOnlyData"
  URL:readonlyStoreURL
  options:nil
  error:&error];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T00:19:28+00:00Added an answer on May 25, 2026 at 12:19 am

    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
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm making a simple page using Google Maps API 3. My first. One marker
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.