我的IF
陈述nsfetchresultscontroller
不起作用,我不知道为什么。IF
这是一个基于视图控制器的静态标题的 简单语句,使用if ([self.title isEqual: @"Abdominals"])
我的故事板可以在下面看到:
视图控制器
- (NSFetchedResultsController *)fetchedResultsController {
if (_fetchedResultsController != nil) {
return _fetchedResultsController;
}
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"ExcerciseInfo" inManagedObjectContext:managedObjectContext];
[fetchRequest setEntity:entity];
NSSortDescriptor *sort = [[NSSortDescriptor alloc]
initWithKey:@"details.muscle" ascending:NO];
[fetchRequest setSortDescriptors:[NSArray arrayWithObject:sort]];
[fetchRequest setFetchBatchSize:20];
// Sort Results
if ([self.title isEqual: @"Abdominals"]) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"details.muscle == %@", @"Biceps"];
[fetchRequest setPredicate:predicate];
}
else if ([self.title isEqual: @"Arms"]) {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"details.muscle == %@", @"Biceps"];
[fetchRequest setPredicate:predicate ];
}
else {
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"details.muscle == %@", @"Chest"];
[fetchRequest setPredicate:predicate ];
}
有什么建议么?