• 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: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?


  • Subject: Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
  • From: "Sean McBride" <email@hidden>
  • Date: Tue, 29 Jun 2010 16:47:18 -0400
  • Organization: Rogue Research Inc.

On Sat, 26 Jun 2010 19:08:29 -0700, Jerry Krinock said:

>> Bottom line : is there a way to make it so that the CoreData object's
>instantiation and its setup are registered as a single action in the
>undo/redo stack ?
>
>I presume that you are setting these attributes in -awakeFromInsert.
>One solution I've seen used for this particular problem is to disable
>undo registration when the attributes are set.  Something like this:
>
>- (void)awakeFromInsert {
>    [super awakeFromInsert] ;
>
>    // Close the curtain so the wizard can do some magic
>    [[self managedObjectContext] processPendingChanges] ;
>    [[[self managedObjectContext] undoManager] disableUndoRegistration] ;
>
>    // Do some magic
>    [self setFoo:whatever] ;
>    [self setBar:whateverElse] ;
>
>    // Re-open the curtain
>    [[self managedObjectContext] processPendingChanges] ;
>    [[[self managedObjectContext] undoManager] enableUndoRegistration] ;
>}

I don't believe that's the right pattern.  In awakeFromInsert/Fetch, one
should be using primitive setters.  The docs say "If you want to set
attribute values in an implementation of this method, you should
typically use primitive accessor methods (either
setPrimitiveValue:forKey: or--better--the appropriate custom primitive
accessors). This ensures that the new values are treated as baseline
values rather than being recorded as undoable changes for the properties
in question."

--
____________________________________________________________
Sean McBride, B. Eng                 email@hidden
Rogue Research                        www.rogue-research.com
Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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: 
 >CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ? (From: Guillaume Laurent <email@hidden>)
 >Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ? (From: Jerry Krinock <email@hidden>)

  • Prev by Date: Re: Tracking multiple NSURLConnections
  • Next by Date: Re: accessing core data sqlite from utility
  • Previous by thread: Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
  • Next by thread: Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
  • Index(es):
    • Date
    • Thread