• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Get Objects from NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Get Objects from NSArrayController


  • Subject: Re: Get Objects from NSArrayController
  • From: Chris Hanson <email@hidden>
  • Date: Mon, 24 Apr 2006 16:53:49 -0700

On Apr 24, 2006, at 4:24 PM, Jason Barker wrote:

Newbie question: How does one go about getting the objects from an instance of NSArrayController as an NSMutableArray object programatically?

The best way to get an object from a controller is to not get the object.[1]


In MVC, controller objects are mediators between model objects and view objects. View objects should be bound to controller objects and controller objects should be bound to model objects. So chances are that you're mixing the layers if you're trying to get an NSMutableArray out of an NSArrayController.

Instead of getting the array from the array controller, you should get the underlying observed collection property from your model object and manipulate it. This is what the methods - mutableArrayValueForKey: and -mutableSetValueForKey: are for (depending on whether the collection you want to manipulate is an array or a set). Any observers of the collection property -- such as bound controllers -- will notice changes you make to the collection and these changes will be propagated to bound views as appropriate.

  -- Chris

[1] Just trying to come up with a memorable "hook"...

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Get Objects from NSArrayController (From: Jason Barker <email@hidden>)

  • Prev by Date: Re: Temporary object created at runtime with Core Data
  • Next by Date: Re: Core-Data, can you issue an NSrequest from awakefrominsert
  • Previous by thread: Re: Get Objects from NSArrayController
  • Next by thread: FYI: Cocoa's framework scaling works great!
  • Index(es):
    • Date
    • Thread