trying again: why do accessors stop "add" from initializing bound value?
trying again: why do accessors stop "add" from initializing bound value?
- Subject: trying again: why do accessors stop "add" from initializing bound value?
- From: Matt Neuburg <email@hidden>
- Date: Sun, 18 Jun 2006 13:58:23 -0700
- Thread-topic: trying again: why do accessors stop "add" from initializing bound value?
Originally I titled this "when automatically prepares content doesn't", but
I'm satisfied that this was due to a misunderstanding of "automatically
prepares content". So forget that and let's try again.
Let's say I have an NSArrayController whose ContentArray is bound to
MyObject's "thing", which is an NSMutableArray ivar. And let's say I bind
columns of an NSTableView to the NSArrayController, in the usual way.
If MyObject has no code, then in the above (very standard) configuration,
pressing the Add button in the interface and editing the columns in the
NSTableView initializes MyObject's "thing" as an NSMutableArray and gives it
an NSMutableDictionary ivar.
But if MyObject has accessors to "thing" (e.g. thing, setThing:,
countOfThing, objectInThingAtIndex:, and so on), then that's no longer true.
I must first manually initialize "thing" (e.g. by saying setThing:
[NSMutableArray arrayWithCapacity:4] in MyObject's awakeFromNib), or else
adding and editing thru the NSArrayController has no effect (i.e. "thing"
remains nil).
Is that a bug? Or is there some basic rule about when an NSArrayController
will create the value to which its content is bound?
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>
_______________________________________________
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