How is a bound NSArrayController so stealthy?
How is a bound NSArrayController so stealthy?
- Subject: How is a bound NSArrayController so stealthy?
- From: Jerry Krinock <email@hidden>
- Date: Tue, 5 Jun 2007 11:38:00 -0700
I have some NSTableColumns bound to an NSArrayController, which is in
turn bound to an NSMutableArray in my model. I'd like a notification
when the user edits an existing item in the table.
In mmalc's ToDos example, after NSLogging all the accessors in
MyDocument.m, I've found that, when the ToDos table is edited, none
of the accessors are invoked. [1] Neither is the array controller
mutating the array returned by (NSArray*)toDos because, after I
modified -(NSArray*)toDos to return an immutable copy, nothing
broke. When I "Save", the toDos returned to
dataRepresentationOfType: and written to the file is complete with
all my edits.
How is NSArrayController able to change the model to which it is
bound so stealthily? I suppose it could be modifying the instance
variable directly a la myDocument->toDos? If so, how can I be
notified? I tried adding self as an observer to key path toDos, but
observeValueForKeyPath:ofObject:change:context: does not get invoked
when I edit an existing table item.
Jerry Krinock
(The reason I want this notification is because I'm having trouble
getting an array to update the model in a "dotted" key path such as
someObject.myDocument.toDos, and while searching for a workaround on
that I discovered this issue. I'm sure it would help immensely if I
understood how this worked.)
[1] None of the following ever gets invoked:
- (void)setToDos:(NSMutableArray *)aToDos
- (unsigned int)countOfToDos
- (id)objectInToDosAtIndex:(unsigned int)index
- (void)removeObjectFromToDosAtIndex:(unsigned int)index
- (void)replaceObjectInToDosAtIndex:(unsigned int)index withObject:
(id)anObject
This one gets invoked when adding a new item, but not when editing an
existing item:
- (void)insertObject:(id)anObject inToDosAtIndex:(unsigned int)index
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden