• 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: [Q] "auto"-incrementing integer attribute in awakeFromInsert
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert
      • From: "Jon C. Munson II" <email@hidden>
References: 
 >RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert (From: "Jon C. Munson II" <email@hidden>)

  • Prev by Date: Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert
  • Next by Date: RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert
  • Previous by thread: RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert
  • Next by thread: RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert
  • Index(es):
    • Date
    • Thread