Come impostare una richiesta di recupero per estrarre solo i dati dall'attributo di un'entità con un valore particolare? Questo è il codice base che ho usato prima.richiesta di recupero per entity.attribute == @ "somevalue"
-(void)fetchResults
{
NSFetchRequest *fetchRequest = [NSFetchRequest fetchRequestWithEntityName:self.entityDescription.name];
NSString *cacheName = [self.entityDescription.name stringByAppendingString:@"Cache"];
// predicate code
if (self.predicate != nil) {
[fetchRequest setPredicate:self.predicate];
}
// end of predicate code
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"name" ascending:YES];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sortDescriptor]];
self.fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:nil cacheName:cacheName];
BOOL success;
NSError *error;
success = [self.fetchedResultsController performFetch:&error];
if (!success)
{
NSLog(@"%@", [error localizedDescription]);
}
}
Ho cercato in questa pagina: http://bit.ly/KevYwR è questa la direzione giusta?
Devo usare NSPredicate
o posso fare a meno?
Grazie per qualsiasi aiuto, punto nella giusta direzione, ecc