title: CoreData iOS - How to create unique ID for objects?
body: <p>I have a project in IOS for iPhones and iPads and such. For the project I am using CoreData to hold the data the user feeds in the app. For ease of understanding lets say its like a contacts app. So basically you know you have your name, work, phone etc. Well this app also stores an image for each "contact". Optionally of course. To prevent the database from being inefficient I store the image into the DocumentsDirectory using the below code for the path. The image is recalled by using the ManagedObjects id which is also what is used in name of image. However, multiple objects can have this same id, which causes some problems.</p>
  
  <pre><code>NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,     NSUserDomainMask, YES);
  NSString *documentsDirectory = [paths objectAtIndex:0];
  NSString *savedImagePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"Person%i.jpg",[[_detailItem id] intValue]]];
  </code></pre>
  
  <p>Basically I am taking the image using the id of the person. However, multiple people can have the same id(An int-32). Instead of doing this, I was wondering if there is a way that CoreData creates or can create a Unique id for each object stored. That way if I change the id it won't lose its picture or if another object has same id it won't use the same picture.</p>
  
  <p>Some databases like a MySQL I used to use had an option for attributes that would give it a unique id for uses with users/forums/posts/etc... Is there something similar in XCode's CoreData? I would hate to have to parse through every object to get a number not being used yet.</p>