• 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: Using an auto incremented NSNumber as attribute in a NSManagedObject
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using an auto incremented NSNumber as attribute in a NSManagedObject


  • Subject: Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • From: Joshua Preston <email@hidden>
  • Date: Thu, 6 Mar 2008 16:49:26 -0500

First, a little head way...

According to some cached documentation (thanks google!) I've located a snippet that appears to do exactly what I require, however, there's a nice notice saying NOT to use this in a production environment. Taking that as a queue, I am assuming that persisting the "nextIndex" or "maxIndex" or whatever I call it and incrementing that value is the preferred way of handling this task. Naturally I can't say that I'm a huge fan of this method, but I suppose it will work, if only for applications with low insertion counts...

If anyone else has a better solution, please feel free :-)

From:http://developer.apple.com/documentation/Cocoa/Conceptual/NSPersistentDocumentTutorial/03_CustomClass/chapter_4_section_4.html

----

The following implementation is crude (and should not be used in a production application—the initial tempID reverts to 1 every time the application is launched), it serves, however, to quickly illustrate the principle.

- (void)awakeFromInsert
{
   static int tempID = 1;

   [super awakeFromInsert];
   self.employeeID = [NSNumber numberWithInt:tempID++];
}
----

As a side note, I think I'm going to cry, it doesn't appear that the iPhone SDK is supported on PPC... sniff sniff... Now I'm kind of upset that I can't get to the rest of the developer documentation...

Regards,

Joshua Preston
email@hidden_______________________________________________

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: Using an auto incremented NSNumber as attribute in a NSManagedObject
      • From: "I. Savant" <email@hidden>
References: 
 >Using an auto incremented NSNumber as attribute in a NSManagedObject (From: Joshua Preston <email@hidden>)

  • Prev by Date: Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • Next by Date: Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • Previous by thread: Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • Next by thread: Re: Using an auto incremented NSNumber as attribute in a NSManagedObject
  • Index(es):
    • Date
    • Thread