Thank you once again, for you invaluable help After breaking this out into a single use project I found that I'd tripped up on spelling
removeObjectFromTestArrayAtIndex removeObjectfromTestArrayAtIndex so the Undo was calling the Lower f and that wasn't KVO so the NSArrayController didn't get the nod to update the TableView correctly. Spending 4 hours tracking this won't be as bad as explaining to the boss;-) Thanks Kevin On 27/01/2011, at 5:02 PM, Quincey Morris wrote: > On Jan 26, 2011, at 19:44, Kevin Bracey wrote: > >> This is not Core Data. > > Er, sorry. I think there was a Core Data vs undo thread recently and I > confused that with this. > >> MyDocument has the NSMutableArray *allImportHeaders, MyDocument has the KVC >> insert and remove messages for this. >> >> I have an NSArrayController bound to allImportHeaders for it's content . >> The NSTableView Columns bound to the NSArrayController >> arrangedObject.xxFieldNames. >> >> I found that sending the NSArrayController a rearrangeObjects fixes this >> problem. > > If the property is being changed KVO compliantly every time, including on > undo and redo, this shouldn't be necessary. The converse is also true -- if > it's necessary, there is (theoretically) a bug somewhere in your code or > design. However, given the inscrutability of the interactions between undo > and NS...Controller objects, I'd say go ahead with whatever seems to work. > (Until it doesn't any more.) > >> I'm now studying the iSpend example and I see a couple of things: >> 1. It only implements - (void)insertTransactions:(NSArray *)objects >> atIndexes:(NSIndexSet *)indexes and - >> (void)removeTransactionsAtIndexes:(NSIndexSet *)indexes not the other KVO >> messages. I wonder why it doesn't do the rest. > > It doesn't need to. There only has to be one insert method and one remove > method. Implementation of the other 4 methods is optional. > >> 2. It uses KVO to listen to those and does the setting of Undo of the Insert >> and Remove there. >> 3. The SubClass of NSArrayController is also Listening for its >> @"contentArray" to change and is sending it's self a rearrangeObjects if it >> does. >> 4. To Implement Undo in the Model object Transaction, they pass in the >> Document to all the Transaction objects so it can access the UndoManager, >> seems a bit anti MVC. > > I haven't looked at iSpend recently, but it used to be a very strange app. It > did some things in convoluted ways to demonstrate advanced techniques. I > don't know what shape it's in now, but I'd tend to use it as a technology > reference more than a pattern for app design. > > _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com