• 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: Core Data Autoincrement?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: Core Data Autoincrement?


  • Subject: re: Core Data Autoincrement?
  • From: Ben Trumbull <email@hidden>
  • Date: Mon, 15 Mar 2010 21:11:09 -0700

> Is there a way (in a Core Data entity) to make an attribute that's
> like a relational DB "autoincrement" field? Or, failing that, does an
> object of class (or subclass) NSManagedObject inherit a "unique"
> UInt32 value that can reliably differentiate it from any other
> instance being managed by the NSManagedObjectContext in use?

Each managed object has an objectID that is unique and automatically assigned.  NSManagedObjectID are opaque value classes, but you can serialize the -URIRepresentation of an objectID.  Mutating the URI form and then reimporting it is unsupported with extreme prejudice.

If you must have an int32 autoincremented, you'll need to create your own.  You can create an entity with a single row to store the integer and update it transactionally.

- Ben

_______________________________________________

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

  • Prev by Date: Re: first responder
  • Next by Date: Re: secure cookie?
  • Previous by thread: Core Data Autoincrement?
  • Next by thread: NSTableView Tab Action
  • Index(es):
    • Date
    • Thread