I added a fetched property to my entity at data model. I did not add its predicate. I retrieve it with fetchRequestTemplateForName, but when execute it I got this error "executeFetchRequest:error: A fetch request must have an entity."
But how come I get this error. Isn't that fetched property a property of my entity ?
So I further debug the issue and find that it was because the retrieved NSFetchRequest == nil
[[self managedObjectModel] fetchRequestTemplateForName:@"somename"];
So how do I fix it ?
Thanks!
Qiu
I assume you created your fetched property in the Xcode model editor and not programmatically. You need to fill out the predicate, otherwise there is nothing to fetch. Therefore, the
NSFetchRequestcomes back asnil.A fetched property is really just a handy shortcut for writing out long-winded fetch requests in code time and again for results you do not want to persist. Maybe it is a good process to first see if your
NSFetchRequestwritten in code works, and then transfer it to the model.