Re: NSArrayController array-observation
Re: NSArrayController array-observation
- Subject: Re: NSArrayController array-observation
- From: mmalcolm crawford <email@hidden>
- Date: Wed, 3 Dec 2003 11:09:20 -0800
On Dec 3, 2003, at 9:07 AM, Dominik Wagner wrote:
Hmm, I started implementing this, and it wasn as much work as I
initially thought. Things worth mentioning:
- The indexed Accessors for to-many propertys only get called if you
don't have normal accessors (-<key>, -set<key>)
Not so, as you'll see if you add logging statements to:
<
http://homepage.mac.com/mmalc/CocoaExamples/AddaYearWithArrayKVC.zip>
The "normal" get and set methods are called for getting and setting the
whole array, but if you add or remove individual elements the
appropriate indexed accessors are called.
- If you do not implement the indexed accessors, then although your
returning a MutableArray in the -<key> accessor, the NSArrayController
always set the whole array on change (addObject:)
Umm, yes. I think this has been covered beofre. From the header file:
- (id)valueForKey:(NSString *)key;
"Given a key that identifies a to-many relationship, return an
immutable array that contains all of the related objects."
Since the array is treated as being immutable, if any modification is
made to it the whole array is "replaced" if it's changed. The
fundamental concept here is encapsulation, and preservation thereof.
See also, though, - (NSMutableArray *)mutableArrayValueForKey:(NSString
*)key;
mmalc
_______________________________________________
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.