i'm inserting new objects into the database by core data. Is there any way to check if there is any duplicate in the database before i insert the values in?
for (int i =0;i<[categoryArray count];i++)
{
Category * cat = [categoryArray objectAtIndex:i];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"ICategory" inManagedObjectContext:managedObjectContext];
NSFetchRequest *request = [[NSFetchRequest alloc] init];
[request setEntity:entity];
ICategory *catt = (ICategory *)[NSEntityDescription insertNewObjectForEntityForName:@"ICategory" inManagedObjectContext:managedObjectContext];
[catt setName:cat.name];
[catt setID:cat.ID];
[catt setPhoto:cat.photo];
[catt setSapphireID:event.ID];
NSLog(@"cattttt have %@", catt);
}
everytime i run the app , it reinsert the values again. i want to check if there is any new category in it if there isnt then i will add that new one in only.