Re: Help with NSArrayController, NSTableView and NSOpenPanel
Re: Help with NSArrayController, NSTableView and NSOpenPanel
- Subject: Re: Help with NSArrayController, NSTableView and NSOpenPanel
- From: George Orthwein <email@hidden>
- Date: Fri, 23 Jun 2006 09:45:38 -0400
On Jun 22, 2006, at 10:50 PM, Kamrin Dahlin wrote:
I guess i was under the impression that the NSArrayController would
automatically get these changes to my Directory model class and i
wouldn't need to make this call programmatically? I guess I don't
really get how bindings are supposed to work. Shouldn't KVO be at
work every time one of my DirectoryModels is created and changed?
I wasn't too sure about this either but I guess not. From
"Programmatically Modifying a Controller’s Contents":
http://developer.apple.com/documentation/Cocoa/Conceptual/
CocoaBindings/Concepts/CntrlContent.html
"The addObject: and removeObject: methods have somewhat different
behavior for NSArrayController. In this case their behavior is the
same as NSArray's addObject: and removeObject: methods. Unlike
NSArray’s implementations, these methods inform the array controller
of the changes so that they can be reflected in the user interface."
I did a test with cocoadevcentral's MailDemo example. When the
Mailbox NSArrayController was bound directly to the mutable array
ivar in MyController through the contentArray binding... I had to
call rearrangeObjects on the arrayController for it to recognize a
change in the ivar. That's why he adds the NSObjectController
"ControllerAlias". As he puts it, it's the bridge to the bindings
system for MyController. Again, a simpler setup is to ditch the ivar,
the contentArray binding and the NSObjectController and just let a
single NSArrayController manage the objects itself.
Also, don't forget you can just call add: on the NSArrayController
for a new object. It inherits the methods of its superclass
NSObjectController.
The link above has a lot of good stuff in it. Check it out. :)
George
_______________________________________________
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