• 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: "Jon C. Munson II" <email@hidden>
  • Date: Mon, 6 Apr 2009 16:02:57 -0400
  • Organization: JTA Enterprises LLC

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:email@hidden]
> Sent: Monday, April 06, 2009 3:19 PM
> To: email@hidden; '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                 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: 
 >RE: [Q] "auto"-incrementing integer attribute in awakeFromInsert (From: "Jon C. Munson II" <email@hidden>)
 >Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert (From: "Sean McBride" <email@hidden>)

  • Prev by Date: Re: [Q] "auto"-incrementing integer attribute in awakeFromInsert
  • Next by Date: SQLite and Unicode
  • 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