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: Thu, 22 Jun 2006 19:50:13 -0700
- Thread-topic: Help with NSArrayController, NSTableView and NSOpenPanel
Hi George...
I added an IBOutlet for my arraycontroller to my MyDocument class and then in the locations where I was adding my Directory model objects to the my NSMutableArray in MyDocument, I instead added them to the arrayController with a [arrayController addObject:DirectoryModel] call. 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?
Thanks for your help! I didn't realize how the NSArrayController actually managed the data of my controller class and it makes sense that it creates and array of objects of it's own. Comming from Java, I am so used to writing all of the DataModel objects for the JTables and JTrees that having it all done for you via these magical controller objects is a bit confusing.
Thanks again,
k
-----Original Message-----
From: George Orthwein [mailto:email@hidden]
Sent: Thu 6/22/2006 7:31 PM
To: Kamrin Dahlin
Cc: email@hidden
Subject: Re: Help with NSArrayController, NSTableView and NSOpenPanel
I think your dirContents array may be redundant. When you assign that
to the NSArrayController then every element of the array controller
will itself be a dirContents mutable array. The NSArrayController
creates its own array of whatever class you assign to it.
That's why when you assigned the array of names to the
NSArrayController they all showed up in the first table row... each
row of the table will be an entire array.
What you really want is an NSArrayController managing the model class
directly. Then you can bind to the dirName key. You won't need to use
the contentArray binding either.
You didn't exactly say what the NSObjectController was for, but it
can probably be removed as well.
(Ok, I just double checked because I've been living in the Core Data
world lately. What I said is true if you use Automatically Prepares
Content on the controller - it will create its own array. You
probably have that off though, so if you want to keep your current
setup using the dirContents ivar as the "contentArray"... I think the
only thing you probably have wrong is entering dirContents as the
Object Class Name in the NSArrayController instead of the name of the
actual model class.)
Hope I understood things enough to help!
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