nil を返す述語と関係があるこのクラッシュに関する他の投稿を読みましたが、私のアプリではこれを理解できません。誰かがこれで私を助けてくれますか?
static NSString *const KJMWorkoutCategorySectionKeyPath = @"workoutCategory";
- (NSFetchedResultsController *)fetchedResultsControllerWithSearchString:(NSString *)searchString {
NSManagedObjectContext *sharedContext; // my NSManagedObjectContext instance...
NSFetchRequest *request = [NSFetchRequest new];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Workouts"
inManagedObjectContext:sharedContext];
request.entity = entity;
request.predicate = [NSPredicate predicateWithFormat:@"(workoutName CONTAINS[cd] %@)", searchString];
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:KJMWorkoutCategorySectionKeyPath ascending:YES];
request.sortDescriptors = @[sortDescriptor];
NSFetchedResultsController *fetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:request
managedObjectContext:sharedContext
sectionNameKeyPath:KJMWorkoutCategorySectionKeyPath
cacheName:nil];
fetchedResultsController.delegate = self;
NSError *error = nil;
if (![fetchedResultsController performFetch:&error]) {
NSLog(@"Unresolved error %@, %@", error, error.userInfo);
abort();
}
return fetchedResultsController;
}