Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert
Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert
- Subject: Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert
- From: "Sean McBride" <email@hidden>
- Date: Mon, 6 Apr 2009 15:18:39 -0400
- Organization: Rogue Research Inc.
On 4/6/09 2:10 PM, Jon C. Munson II said:
>So, I agree Sean that the auto-increment set is being done in a different
>"pass" than the actual add.
>
>However, it seems adding a record can be undone (and redone presumably) -
>just need to press Undo twice.
>
>While that works, I don't think it is the right way to do things. And, one
>shouldn't have to sprinkle custom Undo/Redo code everywhere just to bundle
>the two actions together. This could be a major headache if an add causes
>all kinds of child-adds too.
Turns out it's easy to have it working properly. Just do this in your
'delay 0' method.
[[self managedObjectContext] processPendingChanges];
[[[self managedObjectContext] undoManager] disableUndoRegistration];
[self setValue:[NSNumber numberWithInt:highestIdNumSoFar]
forKey:@"idNumber"];
[[self managedObjectContext] processPendingChanges];
[[[self managedObjectContext] undoManager] enableUndoRegistration];
--
____________________________________________________________
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