此代码会导致错误终止应用程序崩溃,原因是“NSInvalidArgumentException”,原因:“executeFetchRequest: error : fetch请求必须有一个实体。
self.devices = [[managedObjectContext executeFetchRequest:fetchRequest error:nil] mutableCopy];
NSLog(@"point one");
NSString *yourTrip=@"trip1";
NSFetchRequest *request = [[NSFetchRequest alloc] init];
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"thetrip== %@", yourTrip];
[request setEntity:[NSEntityDescription entityForName:@"thetrip" inManagedObjectContext:managedObjectContext]];
[request setPredicate:predicate];
NSError *error = nil;
NSArray *array = [managedObjectContext executeFetchRequest:request error:&error];
if (array == nil)
{
NSLog(@"problemo");
}崩溃特别发生在NSError *error =nil之后;
发布于 2014-03-12 23:12:04
我会改变你的
NSLog(@"problemo");对于一个
NSLog(@"problemo %@", [error localizedDescription]);以获得有关错误的更多信息。
我认为(以及@Wain)您可能没有一个名为“theTrip”的实体(可能是theTrip?请注意,核心数据区分大小写)。带有本地化描述的日志将为您提供一些有关问题的提示。
https://stackoverflow.com/questions/22364991
复制相似问题