Re: CoreData and undo/redo : how to add a managed object with attributes already set in the undo/redo stack ?
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: Guillaume Laurent <email@hidden>
- Date: Fri, 9 Jul 2010 00:09:42 +0200
On Jun 29, 2010, at 22:47 , Sean McBride wrote:
> 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."
Oooh, that's what I was looking for :-). Although I did find an alternative solution thanks to a friend, which is to split the creation of the object and its insertion in the MOC :
NSManagedObject<Segment>* newSegment = [[NSManagedObject alloc] initWithEntity:segmentEntity insertIntoManagedObjectContext:nil];
// do some init stuff on newSegment
[managedObjectContext insertObject:newSegment];
It's a tad easier than your solution in that I don't need to create a custom class for the CoreData object.
Thanks for your replies everyone :-),
--
Guillaume
http://telegraph-road.org
_______________________________________________
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