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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:53:56+00:00 2026-05-31T19:53:56+00:00

Say I have a core data model with a few entities and, throughout the

  • 0

Say I have a core data model with a few entities and, throughout the application’s lifecycle, I’ll be getting and setting properties of these entities from different views.

At least to me, it seems like passing the managed object context around from view controller to view controller and having the controller’s code know about the different entities or derived objects goes against decoupling. As a matter of fact, there is a similar question where the only answer suggests passing around the managed object context.

So, in the spirit of MVC, I thought it might make more sense for view controllers to stick to controlling views, and have a singleton model controller through which these view controllers can query the model to feed their views and notify back when the model needs to be updated based on user interaction with the view.

But I’m not sure how to go about implementing the single model controller interface. For instance, here’s a few ideas:

  • make this controller both a delegate and data source to all view controllers?
  • have the controller be only a data source and use notifications for updates?
  • kvc/o?
  • is the whole idea of a centralized bridge from/to the model just overengineering the MVC pattern? That is, is there some reasonable argument in favor of instead passing the managed context around and this not being considered crappy object-oriented design?

Another thing I’m thinking is, if the singleton controller is a delegate and data source, the methods to get model data and update the model should implement some sort of visitor pattern, right? Meaning, for example, if view controller A allows the user to interact with model entity / object A and some view controller B allows for the same for a model object B, and both view controllers rely on the same delegate, the delegate will have to have some way to know which model entity it should target depending on what concrete controller is calling on it.

I’d appreciate any thoughts / ideas

  • 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-31T19:53:57+00:00Added an answer on May 31, 2026 at 7:53 pm

    In the end, I ended up dropping the delegate / datasource approach for a singleton pattern:

    I figured the following:

    • all controllers are collaborating with a single shared
      managedObjectContext
    • the Core Data model itself revolves around a single “configuration”
      entity (not the configurations that the Core Data literature refers
      to).
    • This “default configuration” is also what all controllers interact
      with, since all other entities exist in the context of this
      configuration entity.

    So essentially, I have a shared resource which should be accessible in a way similar to a global variable.

    So I encapsulated the shared resource in a Singleton through whose interface all other controllers can query and modify the model without knowing much about the internals.

    The general interface allows for things like:

    • [ModelControllerBridge sharedBridge] defaultConfiguration] which
      returns the default shared NSManagedObject
    • [[ModelControllerBridge sharedBridge] newDataSample] which returns a
      new NSManagedObject and internally allocates and inserts it in the
      appropriate entity within the model.
    • [[ModelControllerBridge] shouldCommitChangesToModel] which signals
      the context should be committed to the permanent store
    • etc.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have a couple of Core Data entities .. Student and Exam. These
I have set up a Core Data model where I have two objects, say
So I'm trying to fetch objects from core data. I have list of say
How can I model a mutable lookup table using Core Data? Say I have
Lets say I have a core data model like this one: Item attributes: name
Say you have an application divided into 3-tiers: GUI, business logic, and data access.
I have a somewhat complex data model in my iPad application (an OpenGL drawing
Say I have a Core Data entity called Person. How would I get an
Say you have a Core Data object called Workshop. It has a to-many relationship
I have a Core Data entity with four boolean non-optional properties, defaulted to NO.

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.