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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T13:08:32+00:00 2026-05-30T13:08:32+00:00

Within an application it’s possible to have different UIViewController s that need to share

  • 0

Within an application it’s possible to have different UIViewControllers that need to share the same NSManagedObject. I’m usually do the following:

@interface CustomController : UIViewController

@property (nonatomic, retain) ProductNSManagedObject* productManaged;

@end

Then when I istantiate CustomController I inject it like the following:

customController.productManaged = ....

once done, CustomController is responsible to release it.

This approach works well (I don’t know if is it correct), but what to do when a controller need that object but it’s not a direct child of the controller that has that object? e.g.

MainController -> ChildController -> SubChildController -> ....

where MainController has the managed object.

Do I have to create a lot of intermediary properties or do I need to execute a fresh NSFetchRequest or something else?

The same aspect could be applied to the NSManagedObjectContext. Searching around I’ve found that the context can be grabbed from the application delegate that posseses it (if any). But this approach lacks of flexibility as Marcus Zarra wrote in passing-around-a-nsmanagedobjectcontext-on-the-iphone.

Any suggestions? Thank you in advance.

  • 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-30T13:08:33+00:00Added an answer on May 30, 2026 at 1:08 pm

    This is a very common question (see here and here for related ones). As I wrote in the answers for the related questions, you should stay away from singletons and create a separate object that will take care of object instantiation, of creating the object graph for your application. This separate object can hold references to all shared objects and supply them to the objects being built, so that none of your regular objects has to keep a reference to something just to pass it as a dependency to other objects. See this blog post for more rationale against singleton misuse and for further pointers, especially the articles by Miško Hevery.

    I have created a sample Xcode project that shows how to wire an app without singletons, keeping the coupling low and resolving other singleton issues. It’s very simple at the moment, I will add more common use cases later.

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

Sidebar

Related Questions

Within my application I have 20 or so ViewControllers and Xibs that the user
Within my application, I have a set of filters that can be applied when
I have an application that contains commandLinks within a Primefaces dataTable. The commandLinks link
We have issues within an application using a state machine. The application is implemented
I am implementing instrumentation within an application and have encountered an issue where the
I'm going to be building an application within the next six months that will
In the application delegate within my application I call the following method: - (void)customizeAppearance
I have identified a problem within my application; basically, one sub-routine prepares (lots) of
I have a situation that users access remote MySQL server in C# application. Basically,
I have IronPython hosted within my application, whenever I catch an exception thrown from

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.