Objective-c – Fetched property and NSPredicate

iphoneobjective c

I know how to use NSPredicate with relationships but for some reason when I do the same thing with a fetched property I get:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath address.id not found…' where address is a fetched property.

The code is like this:

[NSPredicate predicateWithFormat:@"address.id == '%i'", id]

Can you even use fetched properties with NSPredicate?

Best Answer

Have you tried [NSPredicate predicateWithFormat:@"address.id == %@",[NSNumber numberWithInt:id]]; ?

if you have address as an object, @"address == %@", addressObject should be sufficient.