CoreData iOS - How to create a unique identifier for objects?

I have an iOS project for iPhones and iPads, etc. For the project, I use CoreData to store the data that the user loads in the application. For ease of understanding, let's say as a contact application. So basically you know that you have your name, job, phone, etc. This application also stores an image for each “contact”. Perhaps of course. To prevent database inefficiencies, I save the image in DocumentDirectory using the code below for the path. The image is called using the ManagedObjects identifier, which is also used for the image name. However, multiple objects may have the same identifier, which causes some problems.

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"Person%i.jpg",[[_detailItem id] intValue]]];

Basically I take an image using the person id. However, several people can have the same identifier (An int-32). Instead, I was wondering if there is a way that CoreData creates or can create a unique identifier for each stored object. Thus, if I change the identifier, it will not lose the image, or if the other object has the same identifier, it will not use the same image.

In some databases, such as MySQL, which I used, there was an option for attributes that would give it a unique identifier for use with users / forums / posts, etc. Is there something similar in Xcode CoreData? I would really like to parse every object so as not to use a number yet.

+1
3

, MySQL, ...

MySQL Core Data. .

, objectID, NSManagedObjectID. , NSURL URIRepresentation. .

, . - , . Core Data .

, . . , , , .

UUID . , :

NSString *newID = [[NSUUID UUID] UUIDString];

.

+5

Core Data . () , Core Data. - UUID.

0

uniqueId - CFUUID,

-1

All Articles