NSError *error = nil;
NSMutableArray *mutableFetchResults = [[managedObjectContext executeFetchRequest:request error:&error] mutableCopy];
if (mutableFetchResults == nil)
{
// Handle the error.
}
// Set self's events array to the mutable array, then clean up.
[self setEventsArray:mutableFetchResults];
[mutableFetchResults release];这些代码给出了一个运行时错误:“executeFetchRequest:error:获取请求必须有一个实体。”有谁可以帮助解决这个错误吗?
发布于 2009-12-18 15:57:16
是的,但是您需要在实际创建fetch请求的地方发布代码,因为该错误消息非常准确地指示您没有正确地配置fetch请求。
特别是,您需要在fetch请求上调用setEntity:。
此外,创建一组fetch请求的可变副本也是不典型的。相反,只需将对象的fetch结果设置为返回的数组(或数组的-copy --不可变数组的不可变副本基本上是免费的)。
https://stackoverflow.com/questions/1926849
复制相似问题