• 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: processPendingChanges and disableUndoRegistration
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: processPendingChanges and disableUndoRegistration


  • Subject: Re: processPendingChanges and disableUndoRegistration
  • From: Quincey Morris <email@hidden>
  • Date: Thu, 25 Dec 2008 19:48:31 -0800

On Dec 25, 2008, at 18:52, christophe mckeon gonzalez de leon wrote:

please pardon the rambling, but i'm just trying to
wrap my head around the semantics involved here.

I think it's simpler than you're assuming it to be. All processPendingChanges does (as far as undo is concerned) is to hand off any pending property changes to the undo manager (possibly winnowing out unnecessary ones -- if a certain property was changed 5 times in a row, for example, they can be coalesced into a single undo action). All disableUndoRegistration does is to cause the undo manager to throw away undo actions handed off to it until told otherwise.


If you're just trying to prevent a document from being 'dirty' just because you opened it, you don't really care what changes are pending or why, you just want to prevent them from getting to the undo manager, so the sequence is:

disableUndoRegistration
... your code that might cause additional changes to the managed object context ...
processPendingChanges
enableUndoRegistration


which is basically what Apple's sample code does.

It doesn't matter what happened before disableUndoRegistration, because whatever it was (if anything) you don't want it to become an undo action. That's better than making it become an undo action and then forcing it to be thrown away.

(If it's possible that something has *already* been registered with the undo manager, then, yes, you'd also want to remove all undo actions and set the document changed state back to unchanged, but typically changes will only result from things you do when opening the document, so you can do them with undo registration disabled.)

The scenario where you would want to put a processPendingChanges *before* the disableUndoRegistration is when you *do* want to register changes up to that point, before you make a change that shouldn't register an undo action.


_______________________________________________

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


References: 
 >processPendingChanges and disableUndoRegistration (From: "christophe mckeon gonzalez de leon" <email@hidden>)
 >Re: processPendingChanges and disableUndoRegistration (From: Jerry Krinock <email@hidden>)
 >Re: processPendingChanges and disableUndoRegistration (From: "christophe mckeon gonzalez de leon" <email@hidden>)

  • Prev by Date: Re: processPendingChanges and disableUndoRegistration
  • Next by Date: [Moderator] Re: Merry Christmas
  • Previous by thread: Re: processPendingChanges and disableUndoRegistration
  • Next by thread: shareware licensing, aquatic prime?
  • Index(es):
    • Date
    • Thread