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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 449k
  • Answers 449k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer 1) (...) Is this true? No it isn't, Hibernate can… May 15, 2026 at 8:16 pm
  • Editorial Team
    Editorial Team added an answer DECLARE @Assignments TABLE ( Id INT NOT NULL IDENTITY(1,1) PRIMARY… May 15, 2026 at 8:16 pm
  • Editorial Team
    Editorial Team added an answer Here's a Linq outer left join version: Dictionary<double, double> dictionary… May 15, 2026 at 8:16 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.