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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:25:44+00:00 2026-06-13T15:25:44+00:00

I’ve been working on adding Core Data into my iPhone app, and I’ve been

  • 0

I’ve been working on adding Core Data into my iPhone app, and I’ve been running into some very frustrating issues. When I call save on my context, the save returns successfully, however no data is getting added to my database(I am running this on the simulator and looking at the SQLITE file to check).

I am using the MYDocumentHandler class from this post to use a single UIManagedDocument across multiple classes. I run the code in my AppDelegate as follows:

if (!self.document) {
    [[MYDocumentHandler sharedDocumentHandler] performWithDocument:^(UIManagedDocument *document) {
        self.document = document;
        self.context = document.managedObjectContext;
        [self loadView];
    }];
}

The loadView method setups up my view controllers once the document has been returned. In my view controllers that use the Core Data I again use something like this:

- (void)viewDidLoad
{
    [super viewDidLoad];

    if(!self.document){
        [[MYDocumentHandler sharedDocumentHandler] performWithDocument:^(UIManagedDocument *document) {
            self.document = document;
            self.context = document.managedObjectContext;
            [self loadAll];
        }];
    }


}

Where the loadAll method setups everything for the view. When I try to save my data, I use the following:

for (int i = 0; i < [jsonArray count]; i++) {
                    NSDictionary *dictionary = [jsonArray objectAtIndex:i];
                    ProjectObject *tempProject = [[ProjectObject alloc] initWithDict:dictionary andETag:etag];
                    [tempAllProjects addObject:[Projects newProject:tempProject withContext:self.context]];
                    [tempProject release];
                }


                [self saveWithContext:self.context];

My saveWithContext method looks like this:

- (BOOL) saveWithContext:(NSManagedObjectContext *)context{
    NSError *error = nil;

    if (context != nil) {
        if ([context hasChanges] && ![context save:&error]) {
            DLog(@"Unresolved error %@, %@", error, [error userInfo]);
        } else{
            DLog(@"save was successful");
            return YES;
        }
    }else{
        DLog(@"context is nil");
        return NO;
    }
}

I always get the save was successful message, and I get the proper messages from the MYDocumentHandler file. Unfortunately, the data is simply not making it to the database. The data is definitely stored in the context, but its not going to the database. Any ideas?

Edit:
Here is the code where I create the Entities:

+ (Projects *) newProject:(ProjectObject *)project withContext:(NSManagedObjectContext *)context
{
    Projects *newProject = nil;
    NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:@"Projects"];
    request.predicate = [NSPredicate predicateWithFormat:@"project_id = %@", project.project_id];
    NSArray *results = [context executeFetchRequest:request error:nil];

    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];

    if([results count] > 0){
        newProject = [results objectAtIndex:0];
        newProject.account_id = [NSString stringWithFormat:@"%@", [defaults objectForKey:@"account_id"]];

    } else {
        newProject = [NSEntityDescription insertNewObjectForEntityForName:@"Projects" inManagedObjectContext:context];
    }

    newProject.account_id = [NSString stringWithFormat:@"%@", [defaults objectForKey:@"account_id"]];
    newProject.project_id = project.project_id;
    newProject.name = project.name;
    newProject.project_description = project.description;
    newProject.updated_at = project.updated_at;
    newProject.starred = project.starred;
    newProject.etag = project.etag;

    newProject.synced = [self hasConnection] ? [NSNumber numberWithInt:1] : [NSNumber numberWithInt:0];
    return newProject;
}
  • 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-06-13T15:25:45+00:00Added an answer on June 13, 2026 at 3:25 pm

    I found the solution in this post. Not sure if this is the best way to handle it. If there is a better option, please let me know.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I have a jquery bug and I've been looking for hours now, I can't
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

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.