Re: mutableArrayValueForKeyPath gives me valueForUndefinedKey
Re: mutableArrayValueForKeyPath gives me valueForUndefinedKey
- Subject: Re: mutableArrayValueForKeyPath gives me valueForUndefinedKey
- From: Charilaos Skiadas <email@hidden>
- Date: Sat, 9 Jul 2005 10:52:57 -0500
On Jul 9, 2005, at 8:32 AM, Michael Hanna wrote:
OK fair enough but then why is it that when this line of code:
NSMutableArray * entriesArray = [self mutableArrayValueForKey:
@"entries"];
gives me a notifying array:
(gdb) po entriesArray
<NSKeyValueNotifyingMutableArray 0x3a8ff0>(
<NSKVONotifying_DLEntry: 0x380840>
)
this line of code:
NSMutableArray *anEntryPassagesArray = [anEntry passages];
does not:
(gdb) po anEntryPassagesArray
<NSCFArray 0x3bf6a0>(
<NSKVONotifying_DLPassage: 0x3e08d0>
)
a DLPassage added to this array does not get observed in the tableview
I think, with my limited understanding of this and hoping someone
else will provide a more authoritative answer, the point is that if
you have an array A of arrays, and you add an element to an an
element of A, then that element of A does not change in any way, it
is the same object. So from the eyes of the array A and anyone
observing it, nothing has changed.
On the other hand, here comes mutableArrayValueForKey. It does
exactly this, creates a mutable array that somehow also notifies its
"parent" when something changes, i.e. propagates the changes
accordingly.
What if you tried [anEntry mutableArrayValueForKey:@"passages"] instead?
Haris
_______________________________________________
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