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: Shawn Erickson <email@hidden>
- Date: Sun, 30 Jan 2005 07:51:18 -0800
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:.
-Shawn
_______________________________________________
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