Re: Undo with NSArrayController
Re: Undo with NSArrayController
- Subject: Re: Undo with NSArrayController
- From: Quincey Morris <email@hidden>
- Date: Wed, 26 Jan 2011 18:49:31 -0800
On Jan 26, 2011, at 17:55, Kevin Bracey wrote:
> I'm trying to patch in Undo and Redo to a NSTableView > NSArrayController > -( void )insertObject:( id )object inAllImportHeadersAtIndex:( NSInteger )index and -( void )removeObjectfromAllImportHeadersAtIndex:( NSInteger )index, using the example from Cocoa® Programming for Mac® OS X, Third Edition.
>
> The Undo and Redo are working BUT (and we like big buts)
> After Undoing an Insert the Object is deleted as expected from vanishes TableView as expected but there is a Ghost blank entry in the TableView as if the NSArrayController is aware of the change.
> So, Add, Add, Add, Undo, Undo, Undo leaves me with 3 Ghost lines in the TableView. It seems that -( NSInteger )countOfAllImportHeaders is not being called.
Hmm, maybe I've spaced out here, but this doesn't look right to me.
What class is 'insertObject:inAllImportHeadersAtIndex:' implemented in? Surely not a subclass of NSArrayController? That's how I first read your description, but I see now that's possibly not what you meant. Is "allImportHeaders" a non-Core Data property of a managed object subclass? Is that where the accessors are?
Why are accessors ('insertObject:inAllImportHeadersAtIndex:') handling undo? They're typically called on both undo and redo, which makes messing with undo hard if you try inside them. If you're handling undo yourself, how are you preventing unwanted interactions with Core Data undo of Core Data properties, which is "automatic"?
So it looks like you're messing with undo, with Core Data, and with the MVC paradigm in ways that are essentially guaranteed to fail. Or maybe I misunderstand your description.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden