title: Is there any way we can restrict duplicate entries in core data?
body: <p>I have been trying to add objects in core data. So, i want that it should not allow duplicate entries in core data store. How to do that?
  This is my code related to save data.</p>
  
  <pre><code>  -(IBAction)save:(id)sender
      {
  
          if([name.text isEqualToString:@""] &amp;&amp; [address.text isEqualToString:@""] &amp;&amp; [phone.text isEqualToString:@""])
          {
  
              UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Yo..!"
                                                          message:@"Data Not Saved"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles:nil];
              [alert show];
          }
      else
      {
          coreDataAppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
  
          NSManagedObjectContext *context = [appDelegate managedObjectContext];
  
  
          NSManagedObject *newContact;
          newContact = [NSEntityDescription
                        insertNewObjectForEntityForName:@"Contacts"
                        inManagedObjectContext:context];
  
  
          [newContact setValue:name.text forKey:@"name"];
          [newContact setValue:address.text forKey:@"address"];
          [newContact setValue:phone.text forKey:@"phone"];
  
  
          name.text = @"";
          address.text = @"";
          phone.text = @"";
  
          NSError *error;
          [context save:&amp;error];
  
          UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Yo..!"
                                                      message:@"Data Saved"
                                                     delegate:nil
                                            cancelButtonTitle:@"OK"
                                            otherButtonTitles:nil];
          [alert show];
  
           NSLog(@"Object Saved\n");
  
      }
  
  
  }
  </code></pre>