title: Core Data: Generate Unique ID Number
body: <p>I have a window that looks like so:
  <a href="https://i.stack.imgur.com/qAjI4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qAjI4.png" alt="UI"></a>
  </p>
  
  <p>Everytime a record is added, I want the repair ID to be set to a unique number that hasn't been used in the table yet. e.g. if there is ID numbers 1,2,3, then when I press +, the ID field should be set to '4'. 
  Also, if one of the records in the table is deleted, so that the ID numbers are: 1,2,4, then when I press +, the number in the Record ID should be set to 3.</p>
  
  <p>At the moment, I have a custom ManagedObject class, where I declare: </p>
  
  <pre><code>-(void)awakeFromInsert {
      [self setValue:[NSDate date] forKey:@"date"];
  }
  </code></pre>
  
  <p>In order to set the date to today's date.</p>
  
  <p>How would I go about implementing this unique record ID?</p>
  
  <p>Thanks!</p>