我讀過關於這次崩潰有關與謂詞返回零有關的其他職位,但即時通訊無法與我的應用程序弄清楚。有人可以幫助我嗎?NSInvalidArgumentException',原因:'無效的謂詞:無RHS,需要幫助搞清楚這
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;
}
它是否在'predicateWithFormat'行或'set謂詞線? –
它正好在下面的行崩潰:'if(![aFetchedResultsController performFetch:&error])' – kevnm67