• 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
Re: Undo with NSArrayController
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undo with NSArrayController


  • Subject: Re: Undo with NSArrayController
  • From: Quincey Morris <email@hidden>
  • Date: Wed, 26 Jan 2011 20:02:31 -0800

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 (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

  • Follow-Ups:
    • Re: Undo with NSArrayController
      • From: Kevin Bracey <email@hidden>
References: 
 >Undo with NSArrayController (From: Kevin Bracey <email@hidden>)
 >Re: Undo with NSArrayController (From: Quincey Morris <email@hidden>)
 >Re: Undo with NSArrayController (From: Kevin Bracey <email@hidden>)

  • Prev by Date: Re: Undo with NSArrayController
  • Next by Date: Programmatically create view and handle events
  • Previous by thread: Re: Undo with NSArrayController
  • Next by thread: Re: Undo with NSArrayController
  • Index(es):
    • Date
    • Thread