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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:47:33+00:00 2026-05-10T23:47:33+00:00

Lets say I have a view, myView, a view controller, myViewController, and some sort

  • 0

Lets say I have a view, myView, a view controller, myViewController, and some sort of model object, myModel. Further, lets say the model has two KVO compliant properties, arrayOfPeopleNames and arrayOfAnimalKinds (both NSStrings).

In my view I want to have two pop-ups bound to the contents of these two arrays.

My question is, if myController has a reference to myModel, and the dropdown is bound to myViewController is it good practice to set a keypath along the lines of myModel.arrayOfPeopleNames?

Or do I need to set up an additional NSArray in myViewController which mirrors the one in myModel and bind to that keypath instead?

The former seems a lot simpler from an implementation point of view (I don’t have to make the controller array mirror the model array), but I’m wondering about whether it exposes the model to much to the view.

Opinions?

  • 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. 2026-05-10T23:47:33+00:00Added an answer on May 10, 2026 at 11:47 pm

    You shouldn’t mirror the model’s array in the controller. Although I wouldn’t be too concerned about binding directly to the model’s array in a very simple case, you could also bind your UI objects to an NSArrayController, which manages the model’s array. This would provide separation between the model and UI, and more importantly handle tasks like sorting, selection, adding and removing objects, and so on.

    I can see where you’re coming from by being concerned KVO and bindings violates ‘pure’ model view controller design, but it’s not something you should worry about. Even though the KVO notifications pass directly to the view from the model, setting up and changing the connection between the view and model is still the responsibility of the controller (only in this case it’s done through IB instead). For instance, you wouldn’t want a model object to get a reference to the view, and bind itself to the UI, that would be the controller’s responsibility.

    As another example of something to avoid, consider if instead your model had an array of ‘animal IDs’ instead of names. Instead of creating a method to translate animal IDs to human readable animal names in the model, you might instead want to create a value transformer or formatter to do the conversion. This allows you to maintain that level of separation between the model and view.

    Keep in mind also that the purpose of design patterns is to reduce the complexity of coding a solution to a problem, never to increase it. You’ll see that this is exactly the way Cocoa works, even though it might not always adhere to the strictest definition of a pattern.

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

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is a very old idea, first implemented in the… May 11, 2026 at 8:47 pm
  • Editorial Team
    Editorial Team added an answer There is ASP.NET Merge tool (Aspnet_merge.exe) and Web Deployment Projects… May 11, 2026 at 8:47 pm
  • Editorial Team
    Editorial Team added an answer If you're only looking at the last four digits, you… May 11, 2026 at 8:47 pm

Related Questions

For Example: Let's say that I want to return a view that displays a
I'm having a right barney getting my head around how everything fits together using
is it possible to do something like this: Let's say I have a lot
I'm brand new to MVC and, as a learning exercise, I'm trying to re-write

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.