re: Core Data Autoincrement?
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