RE: Help with NSArrayController, NSTableView and NSOpenPanel
RE: Help with NSArrayController, NSTableView and NSOpenPanel
- Subject: RE: Help with NSArrayController, NSTableView and NSOpenPanel
- From: "Kamrin Dahlin" <email@hidden>
- Date: Fri, 23 Jun 2006 08:33:56 -0700
- Thread-topic: Help with NSArrayController, NSTableView and NSOpenPanel
Hey George,
Thanks for all of your help.
I will dig into the Cocoa Bindings article today. I started reading it last night, but didn't make it as far as the link you provided. Could you maybe answer one more question for me.
If I have an existing array of objects and I want to display each one of the objects in the array on its own row of my table, how can I make this happen via bindings? My application is setup with a model that will be used for other things, so having the array of directoryContents inside of each of my DirectoryModel objects is needed. I have the NSArrayController managing the DirectoryModel objects now, but I am not sure how to make a second table display the individual values of my DirectoryModels directoryContents array. I have tried hooking it up to its own NSArrayController, but end up with a single row of all of the values.
Hopefully that makes sense.
And again, you have been a huge help and I really appreciate it.
thx
k
-----Original Message-----
From: George Orthwein [mailto:email@hidden]
Sent: Fri 6/23/2006 6:45 AM
To: Kamrin Dahlin
Cc: email@hidden
Subject: Re: Help with NSArrayController, NSTableView and NSOpenPanel
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