Closed kylef closed 10 years ago
What is the justification behind coming up with our own ID generation though. It's not a requirement that an API index it's objects nor can we rely on it.
I'm not quite sure if I understand this question correctly, does the attached commit answer your question?
This means that any API client should use the objectWithPrimaryKey:inManagedObjectContext: method instead of having its own "unique id" parameter on an entity. — Sent from iPhone
On Mon, Apr 15, 2013 at 2:37 AM, Calvin Cestari notifications@github.com wrote:
What is the justification behind coming up with our own ID generation though. It's not a requirement that an API index it's objects nor can we rely on it.
Reply to this email directly or view it on GitHub: https://github.com/kylef/KFData/issues/26#issuecomment-16363786
My question was 'what is being passed in from the client as (NSUInteger)primaryKey'? Is this the position within an array? If so, what about a parsed top-level NSDictionary object that has no position?
Primary key is the primary key an API would use. Example code from an API:
NSDictionary *JSONDictionary;
NSNumber *objectID = [JSONDictionary valueForKey:@"id"]; // = @4;
Person *person = [Person objectWithPrimaryKey:objectID inManagedObjectContext:managedObjectContext];
Yeah, I get what you were meaning now.
So all we would need to do is grab the persistent store identifier for the store we want to store the entity in. Then insert the entity name and unique ID from an API. I'm guessing the P is for primary key.
This would ensure we always have a unique entity for any upstream ID.
25