Q:

NSPredicate for NSNumber property of NSManagedObject

I have NSNumber * year property of NSManagedObject, it's type in data model is Integer 16.
I try to check with NSPredicate for this year, but can't find the right one.
What I tried:
NSPredicate *p = nil;
NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
NSNumber *yearNo = [nf numberFromString:term];
if (yearNo) {
    p = [NSPredicate predicateWithFormat:@"(cars.year == %i)", yearNo.intValue];
}

I also tried:
NSPredicate *p = nil;
NSNumberFormatter *nf = [[NSNumberFormatter alloc] init];
NSNumber *yearNo = [nf numberFromString:term];
if (yearNo) {
    p = [NSPredicate predicateWithFormat:@"(cars.year == %@)", yearNo];
}

In both cases app crashes.

A:

If you provide more details for your model, we could help you.
But I think the problem is due to cars. If cars is to-many you need a modifier for this
[NSPredicate predicateWithFormat:@"ANY cars.year == %@", yearNo];

A:

As @flexaddicted already said, you have not supplied sufficient information, e.g. for which entity the fetch request is made.
If you want to fetch Car objects with a given year, the predicate is just 
[NSPredicate predicateWithFormat:@"year == %@", yearNo]

