Re: Modifying the array of an NSArrayController
Re: Modifying the array of an NSArrayController
- Subject: Re: Modifying the array of an NSArrayController
- From: Henrik Wittland <email@hidden>
- Date: Fri, 7 Nov 2003 16:14:39 +0100
Subclassing NSArrayController and overriding newObject to initialize
new objects seems rather complicated to me. I think Aaron Hillegass is
right with his suggestion to add some delegate methods like
arrayController:willAddNewObject: to NSArrayController.
There are more options as subclassing or delegation. But subclassing
isn't the worst. You have only to subclass once and
make it reusable for your architecture. You can even implement the
delegates or
you can implement
+ (void)exposeBinding:(NSString *)binding;
on your controller subclass. Give it a new binding called
"templateObject" and bind this to your modell.
So newObject: could make a copy of this templateObject and insert it
into the array.
"We like to have options" :-)
I have one more question concerning KVO though. The documentation says
this about automatic change notifications:
http://developer.apple.com/documentation/Cocoa/Conceptual/
KeyValueObserving/Concepts/AutoVsManual.html
Automatic key-value observing informs observers of all changes made
through key-value compliant methods, the key-value coding methods, as
well as directly assigning a value to an instance variable. The
examples shown in Listing 3-1 result in any observers of the property
name to be notified of the change.
From the examples:
// assigning an instance variable directly
name=[newSavingsName retain];
How can the run-time system notice a change to the actual instance
variable? Isn't this just like accessing a memory location? I thought
this was only possible using some kind of debugging technique, like a
breakpoint?
This has to be a mistake in the documentation. It is not mentioned in
the header files and it definitively does not work this way.
Regards,
Henrik
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.