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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:21:28+00:00 2026-05-15T15:21:28+00:00

I’m running into a crash issue while developing an iPhone app with Core Data.

  • 0

I’m running into a crash issue while developing an iPhone app with Core Data.

The app syncs data with a webservice on a background thread.

When the app first launches, the existing data in the Core Data DB will be displayed to the user in a UITableView, while a background thread is kicked off the grab the latest data from the web service API. Lets call the core data models User and Items, just for discussion purposes with a User having many items. The items are what is displayed in the UITableView.

When the API results come back, the users existing Item records are deleted from Core data and the new set of Item records is inserted into Core Data. Once all items are parsed, a message is sent back to the main thread to merge in the core data changes and refetch the data from CD.

However, I keep crashing in my configure table cell routine, and I’m sure its because of out of scope objects. Meaning, the main thread is trying to display objects from Core Data, while the background thread is deleting those same objects from Core data and replacing them with new ones.

What is the best way to handle these kind of conflicts? Do I have to put in some kind of mechanism to not kick off the background thread updating until the main view has loaded/displayed all its data? If so, how do I accomplish this? Can I still keep my same methodology and just handle the deletion of displayed items better?

  • 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-15T15:21:29+00:00Added an answer on May 15, 2026 at 3:21 pm

    Refer to the TopSongs project SongsViewController implementation
    Specifically viewDidLoad and handleSaveNotification

    - (void)handleSaveNotification:(NSNotification *)aNotification {
    [managedObjectContext mergeChangesFromContextDidSaveNotification:aNotification];
    [self fetch];
    }
    

    Your viewController’s handleSaveNotification: is not being called because you registered for notifications from the MOC that it owns, not all MOC’s. It works for the the TopSongs sample as the app delegate and viewController’s MOC are the same object. (appDelegate passes the moc to songsViewController).

    Replace:

    // ViewController.m viewDidLoad
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSaveNotification:) name:NSManagedObjectContextDidSaveNotification object:self.managedObjectContext];
    

    With:

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleSaveNotification:) name:NSManagedObjectContextDidSaveNotification object:nil];
    

    Replace:

    // ViewController.m viewDidUnload
    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextDidSaveNotification object:self.managedObjectContext];
    

    With:

    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSManagedObjectContextDidSaveNotification object:nil];
    
    • 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 have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am writing an app with both english and french support. The app requests
I am using Paperclip to handle profile photo uploads in my app. They upload
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have some data like this: 1 2 3 4 5 9 2 6

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.