Actually, since I'm using a fetch in the routine to get the next value, the
processPendingChanges call didn't seem to be necessary (at least for my
app), so I was able to just use the disable/enable messages around the ID
portion.

When I tested that, it worked just peachy! :)

Thanks for that!

Peace, Love, and Light,

/s/ Jon C. Munson II


> -----Original Message-----
> From: Sean McBride [mailto:s...@rogue-research.com]
> Sent: Monday, April 06, 2009 3:19 PM
> To: jmun...@his.com; 'Cocoa Developers'
> Subject: Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert
> 
> 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                 s...@rogue-research.com
> Rogue Research                        www.rogue-research.com
> Mac Software Developer              Montréal, Québec, Canada


_______________________________________________

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

Reply via email to