On 18 Jul 2011, at 01:12, Gideon King wrote: > Hi all, in the documentation "Using Managed Objects", it says that we should > use: > > [moc processPendingChanges]; // flush operations for which you want undos > [[moc undoManager] disableUndoRegistration]; > // make changes for which undo operations are not to be recorded > [moc processPendingChanges]; // flush operations for which you do not want > undos > [[moc undoManager] enableUndoRegistration]; > > When disabling undo registrations, but in the example code for both Adding a > Department Object, and A Sheet for Creating a New Employee, it uses: > > [[managedObjectContext undoManager] disableUndoRegistration]; > // Do stuff > [managedObjectContext processPendingChanges]; > [[managedObjectContext undoManager] enableUndoRegistration]; > > (i.e. it only does a processPendingChanges once instead of twice) > > I was doing some performance tuning of my application and it appeared that > the processPendingChanges is a moderately expensive operation, even when > there are basically no pending changes, so I tried removing the first > processPendingChanges as per the examples, and it still seems to be working > correctly. > > Does anyone know of any reason why the first processPendingChanges would be > necessary?
Yes, if some unprocessed changes had already been made to the context that you *do* want on the undo stack. Without a call to -processPendingChanges, those would only be processed while registration is disabled, which probably isn't the desired result. _______________________________________________ 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