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
Thanks for answering my question. I added predicate as you suggested but NSFetchRequest still returned nil. Then I suddenly realized that I actually added Fetched Property NOT Fetch Request to my entity and that's the reason fetchRequestTemplateForName return nil. So I add Fetch Request (in Editor menu there are "Add Fetch Request" and "Add Fetched Property" menu items) and that fixed the problem! So sorry for the confusion :$.
But my question then is why we need fetched property as we already have fetch request ? I know apple document said something like "Fetched properties represent weak, one-way relationships." But I still feel confused b/c fetch request seems more straightforward.