0

我的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 ];

 }

有什么建议么?

4

1 回答 1

0

我想你正在寻找isEqualToString:

isEqual:比较对象,您希望在其中比较值。

于 2013-07-02T18:13:31.920 回答