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 7675505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:58:45+00:00 2026-05-31T16:58:45+00:00

There is something I dont understand in core data. I have created a NSManagedDocument,

  • 0

There is something I dont understand in core data.
I have created a NSManagedDocument, made a change, and saved it.
Then I created another one and opened the file I saved.
From what I understand the NSManagedDocument should have the change I mad, but it doesn’t.

here is the code I wrote:

NSURL *url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
url = [url URLByAppendingPathComponent:@"Data Base"];
// url is now "<Documents Directory>/Default Photo Database"
self.dataBase = [[UIManagedDocument alloc] initWithFileURL:url];

if (self.dataBase.documentState == UIDocumentStateClosed) {
    [self.dataBase openWithCompletionHandler:^(BOOL success) {
    }];
} 
Position *pos = [NSEntityDescription insertNewObjectForEntityForName:@"Position" inManagedObjectContext:self.dataBase.managedObjectContext];
pos.name = @"positon 1";


[self.dataBase saveToURL:self.dataBase.fileURL forSaveOperation:UIDocumentSaveForOverwriting completionHandler:^(BOOL success){

}];

self.dataBase = [[UIManagedDocument alloc] initWithFileURL:url];

if (self.dataBase.documentState == UIDocumentStateClosed) {
    [self.dataBase openWithCompletionHandler:^(BOOL success) {
    }];
} 
pos = [NSEntityDescription insertNewObjectForEntityForName:@"Position" inManagedObjectContext:self.dataBase.managedObjectContext];
pos.name = @"position 2";

as far as i understand I should have 2 objects for entity “Position” by now, but I only have the last one, why is that?

what am I missing here?

  • 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-31T16:58:46+00:00Added an answer on May 31, 2026 at 4:58 pm

    I don’t know why, but as soon as I moved my code to the AppDelegate it was solved…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

there is something about my code that i dont understand. when i execute the
I'm guessing there's something really basic about C# inheritance that I don't understand. Would
I have created a strongly typed dataset in the VS 2005 Dataset Designer. There
I'm battling to understand the problem I'm having with Core Data and a simple
This is something i just can't figure out working with Core Data. I want
I'm getting some unexpected results calling one makefile from another. I have two makefiles,
Just started working with Mercurial a few days ago and there's something I don't
I think there must be something subtle going on here that I don't know
Is there something like the Python descriptor protocol implemented in other languages? It seems
Is there something special about Safari for Windows and AJAX? In other words: Are

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.