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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:00:50+00:00 2026-06-12T07:00:50+00:00

I am writing a Core Data app and I’ve started passing my objects around

  • 0

I am writing a Core Data app and I’ve started passing my objects around to my views & managers. For example, my UIImageView subclass knows how to pull the image data out of the object, and if the image data hasn’t been loaded it knows how to fetch, assign, and use the image. I have a singleton manager to upload data to the server and those take managed objects and then update them with the server IDs on successful uploads.

This seems to be the wrong approach now that I am deleting managed objects (server tells me the objects have been deleted on the server side). The problem is that objects can get deleted out from underneath my views & managers.

Some more examples: If a completion block is still holding the object, it will be called with a deleted managed object. If a notification or user event makes it to a view before it disappears, it will attempt to access a deleted object as well. Yes, my table views / collection views will refresh and remove the associated views when underlying objects are deleted (and no longer match my fetch predicates), but there are still completion blocks.

Is it safe to be passing managed objects around like this if objects are going to be deleted? This approach so far has worked like a dream, I’m starting to think I need to completely decouple managed objects from all of my views and managers. That is, the controller fetches objects, creates the views/cells and sets all of the needed data (including IDs to reference the objects when delegate actions happen), and then lets the objects fault out again. When a user interacts with the view in any way, it must call back to the controller, fetch the associated object, and use that data. Should I stop holding on to my managed objects, or is there a clean way to just check .isDeleted all over the place?

  • 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-12T07:00:51+00:00Added an answer on June 12, 2026 at 7:00 am

    If your moc is only doing work on the main thread, then its probably not too dangerous but not what I would say is a good design decision. If you are doing your moc work off the main thread (private dispatch queue or using the new-ado-of-ios5 option to have the moc use a private queue), then what you are doing is foolhardy.

    I have a similar design but use the new-private-queue option on the moc. Any object that wants something from the moc must get it via my singleton’s interface, which does uses a ‘performBlock’ command. The nice thing about this design is that when I write, I just use ‘performBlock’. Retrieving information is obviously done using ‘performBlockAndWait’.

    This interface gives me a lot of freedome to refactor the Core Data code and not have to touch anything else (which I’ve done 4 times now).

    EDIT: There is more specifics in this link

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

Sidebar

Related Questions

I'm writing an iOS app which utilizes Core Data (NSManagedObject, NSManagedObjectContext..etc) and I was
I am writing my first comprehensive app using Core Data, and I want to
I am writing an iPhone app which uses core data for storage. All of
I'm considering using Core Data for an app I'm writing. However, after reading the
I am writing an app which uses core-data to store my data. Included in
I am writing a Mac app that uses Core Data as its persistence layer,
I am writing my first core data app. For some reason, my edits are
I'm writing an iOS app and I'm using Core Data to store a series
In my app that I'm writing, I am use Core Data for persistent store.
I recently found myself writing a piece of code that executed a Core Data

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.