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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:59:11+00:00 2026-06-14T08:59:11+00:00

I have searched through SO looking for different ways to share data between view

  • 0

I have searched through SO looking for different ways to share data between view controllers. I see that delegation to pass back data are the most common way ppl suggest, and that some ppl use singletons for the information to be available from anywhere in the app. I am not familiar with Core Data yet, but from what i’ve looked at so far, it seems like Core Data is similar to a Singleton in that from the ManagedObjectContext, you can access the data. So as long as you have a reference to that object, you can access that data (feel free to correct me if that understanding is wrong).

In this scenario, I was wondering if delegation or singletons should be used. I basically have a tab bar controller with two tabs. One tab passes data back and forth between the views using delegation or assigning a property on the view to be presented.

The second tab is a summary view of the first tab. So on a completely different stack of views, I need that same data that was in Tab one. In that scenario, should I be using a Singleton so it can be accessed from everywhere in the app? Or is there a better solution?

Also, I’m wondering what you would do about archiving your data if your application is about to be closed. It seems like to me, if I did implement a singleton, when I receive the notification that my app is going to enter the background, I can look in my singleton and save the data. But if I don’t use a singleton, how would I save the data when the app enters the background. Do I put that saving code in the app delegate instead.

I guess in the end I’m trying to understand what design pattern is better in this scenario for archiving and sharing data between the app. Thanks!

  • 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-14T08:59:12+00:00Added an answer on June 14, 2026 at 8:59 am

    I went through this nice tutorial on Core data:
    http://timroadley.com/2012/02/09/core-data-basics-part-1-storyboards-delegation/

    The approach used there is: your ManagedObjectContext is initialized for the first time in your AppDelegate. Then in my root view controller, i retrieve the ManagedObjectContext from the appdelegate. Then in prepareForSegue, pass the managedObjectContext to the pushed view Controllers.

    The AppDelegate has the readonly accessor property for the __managedObjectContext, which is responsible for creating this singleton object for the first time.

    In each view controller, I set up the fetchedResultsController on viewWillAppear with the entities I want from core data. I then write directly to core data when the user hits the save button. In my particular application, i have an explicit “Cancel” button, because the user can make mistakes, or wipe out the editable text data accidentally. But you could persist changes immediately, upon each control’s changed value, like in the “Settings” menu in iOS. I prefer the Cancel/Save approach simply because of the nature of my data. Some research is in order to see if you must re-save the whole object, or can only update individual fields in coredata.

    Core data pretty much takes care of your questions, if you read/write directly from managedObjectContext. Data is persisted right away, and updated right away. If you have data that is not persisted on purpose, then delegation is a good way to pass it between screens. If you need to notify a whole bunch of view controllers that you don’t want to know about with non-persisted data, consider using NSNotificationCenter with object or with dictionary.
    Send and receive messages through NSNotificationCenter in Objective-C?

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

Sidebar

Related Questions

I have an application that is looking through some files for old data. In
I have searched through internet & found that there are no any direct method
I have searched through many times but have not seen this before. Probably really
I have searched through the net and still have no clue how to do
Im trying to translate an object without using glTranslate(). I have searched through web
I have a simple form that searches through the 2000+ issues of a 3rd
I have searched for this, and i found that for api less than 12,
I have searched up and down the internet for a jQuery widget that does
I have searched through the google and also joomla forums but didn't got what
OK so I have tried a few differrent ways and searched the forums. I've

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.