keypath objectID not found in entity exception

cocoa, core-data, ios, ipad, iphone

Solution

The answer given in THIS link still holds here. It holds in the sense that you use the same predicate:

NSPredicate* p = [NSPredicate predicateWithFormat:@"SELF = %@",book.objectID];

But you supply the `objectID` as parameter.

CoreData allow comparison of `objectID`s and objects when fetching from the store. it probably has to do with the fact that an `objectID` is used for a one-to-one mapping to a managed object (hence the use of SELF which is a predicate reserved word and not a property name).

Problem

I'm facing this strange issue when trying to fetch some objects after their objectID. The error complains that there is no such thing as an objectID key path, but the managed object should respond to that. The error is not thrown all the time, which makes me think it could be a concurrency problem, although I've double checked and each context performs the operations on its own thread. Here is the predicate, although it looks sane to me: `[NSPredicate predicateWithFormat:@"objectID == %@", book.objectID]` Edit: Regarding this answer. I didn't tried using the object itself, I need to use the objectID because of multithreading considerations.

Original source

Related problems