Xcode编译器继续告诉我在FATAL中的F之前错过了一个括号(错误已注释掉),但我无法理解这一点。你能告诉我什么缺失或需要改变吗?
-(void)viewDidLoad
{
// 1
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
// 2
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Location"
inManagedObjectContext:self.managedObjectContext];
[fetchRequest setEntity:entity];
// 3
NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES];
[fetchRequest setSortDescriptors:@[sortDescriptor]];
// 4
NSError *error;
NSArray *foundObjects = [self.managedObjectContext executeFetchRequest:fetchRequest error:&error];
if (foundObjects == nil) {
FATAL_CORE_DATA_ERROR(error); // Expected ']' (F in FATAL highlighted)
return;
}
// 5
_locations = foundObjects;
}