• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How is a bound NSArrayController so stealthy?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: How is a bound NSArrayController so stealthy?
      • From: Shamyl Zakariya <email@hidden>
    • Re: How is a bound NSArrayController so stealthy?
      • From: Keary Suska <email@hidden>
  • Prev by Date: Re: [CoreData] Background Insertion
  • Next by Date: Re: Mac Disk burning API:s
  • Previous by thread: Re: Recursion taking up far too much memory... any ideas?
  • Next by thread: Re: How is a bound NSArrayController so stealthy?
  • Index(es):
    • Date
    • Thread