I have a sample program that use Core Data and load an sqlite database in it. And I am displaying all the values using this code
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Name"
inManagedObjectContext:context];
[fetchRequest setEntity:entity];
NSArray *fetchedObjects = [context executeFetchRequest:fetchRequest error:&error];
for (Name *name in fetchedObjects) {
NSLog(@"ID: %@", name.nameId);
NSLog(@"First Name: %@", name.first);
NSLog(@"Middle Name: %@", name.middle);
NSLog(@"Last Name: %@", name.last);
}
This code works fine, my problem here is that I can’t select a specific data/record. Example I want to select the record with the ID = 1.
Thanks!
You have to use predicates (with NSPredicate) before your request execution.
Something like that :