我正在尝试编写一个基于我传入的 ID(NSInteger 值)执行提取的方法。我可以对所有内容进行提取,但是当我添加谓词时,程序会崩溃。我是否做错了谓词。
-(BOOL)finding:(NSInteger)theID
{
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self == %i",theID];
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc]init];
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Course" inManagedObjectContext:_cdStack.managedObjectContext];
[fetchRequest setEntity:entity];
[fetchRequest setHavingPredicate:predicate];
NSError *error = nil;
NSArray *fetchedObjects = [_cdStack.managedObjectContext executeFetchRequest:fetchRequest error:&error];
}