Re: Best way to set default values for "added" objects bound to NSArrayController?
Re: Best way to set default values for "added" objects bound to NSArrayController?
- Subject: Re: Best way to set default values for "added" objects bound to NSArrayController?
- From: Mark Munz <email@hidden>
- Date: Sun, 30 Jan 2005 10:52:32 -0600
That helps a lot. I didn't catch the newObject and prepareContent
before, forgot to look at NSObjectController for the creating of an
individual object. Since my object is an NSMutableDictionary, it looks
like subclassing is required since I want to setup default keys/values
for newly created objects.
Many Thanks.
Mark
On Jan 30, 2005, at 9:51 AM, Shawn Erickson wrote:
On Jan 30, 2005, at 7:05 AM, Mark Munz wrote:
Is subclassing NSArrayController and overriding addObject: the best
way to setup default values for newly created object
(NSMutableDictionary) or is there a way to do that without
subclassing?
First note that NSArrayController is a sub-class of NSObjectController
and that class supports automatic initialization.
Automatic when enabled (setAutomaticallyPreparesContent:YES or in
bindings panel) will call the controllers newObject method which
causes the object to be created and the standard init method to be
called. So if the object type you are adding to the array can set its
defaults in its own init method then you should likely use this
method.
Otherwise I believe you sub-class NSArrayController and override
either prepareContent and newObject or both depending on what you need
to do. I think that is better then attempting to override addObject:.
_______________________________________________
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