żądanie pobrania dla entity.attribute == @ „somevalue”
Jak skonfigurować żądanie pobierania, aby pobierać tylko dane z atrybutu jednostki z jedną określoną wartością? To jest podstawowy kod, którego użyłem wcześniej.
-(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]);
}
}
Patrzyłem na tę stronę:http://bit.ly/KevYwR czy to właściwy kierunek?
Czy muszę korzystaćNSPredicate
czy mogę się obejść?
Dziękujemy za pomoc, wskaż właściwy kierunek itp.