I have the following two entities in my Core Data Model:
Manufacture {name, ...other attributes}
Product {name, .... other attributes}
I have setup a One to Many Relationship:
Manufacturer.manufactures <------>> Product.manufacturedBy
I am trying to build a predicate to return all Products belonging to Manufacturers that match a search string. E.g. if there are two Manufacturers, "King Nut", and "Queen Nut" then a search on "Nut" should return all products made by both King Nut and Queen Nut.
My predicate works perfectly when my filter is on the Product entity, however I cannot get any predicate to work when filtering on the Manufacturer entity. The result set is empty.
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Product" inManagedObjectContext:[GBKDB context]];
searchValue = @"nut";
NSString *wildcardString = [NSString stringWithFormat:@"*%@*", searchValue];
I have tried the following:
predicate = [NSPredicate predicateWithFormat:@"manufacturedBy.name CONTAINS[cd] %@",searchValue];
predicate = [NSPredicate predicateWithFormat:@"manufacturedBy.name like %@",wildcardString];
predicate = [NSPredicate predicateWithFormat:@"manufacturedBy.name matches %@",wildcardString];
predicate = [NSPredicate predicateWithFormat:@"ALL manufacturedBy.name like %@",wildcardString];
predicate = [NSPredicate predicateWithFormat:@"ALL manufacturedBy.name like[cd] %@",@wildcardString];
"when filtering on the Manufacturer entity"
? if you try to fetchProduct
s, your requests entity must beProduct
β Dan Shelly