I have a large array for Person entities, and want to filter them before importing into my Core Data database, so that each Person will be only once in the database based on the name. The names are pulled from a database, and have the format: @"Jones, A."
After some searching, I came up with the following: NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; [fetchRequest setEntity: [NSEntityDescription entityForName: @"Person" inManagedObjectContext: context]]; [fetchRequest setPredicate: [NSPredicate predicateWithFormat: @"name IN %@", persons]]; NSError *error; NSArray *filteredPersons = [context executeFetchRequest: fetchRequest error: &error]; // get the difference NSMutableArray *uniquePersons = [NSMutableArray arrayWithArray: persons]; [uniquePersons removeObjectsInArray: filteredPersons]; And then import them. As it turns out, filteredPersons is always empty, even though I know certain names are already present How can I make this work? Thanks, - Koen. _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com