I have a core data class, SSSLicense that has attributes like name and type. It inherits from an abstract entity called SSSArchivableEntity which has a boolean attribute named isArchived (among others).
I've already fetched the full set of license entities from the DB and am now trying to filter based on type and the isArchived flag. However, despite many variations of my predicate, I cannot get a valid result.
Here is the relevant code:
NSSet *licenses = [person licenseList] ;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(licenseType like %@) AND (isArchived == NO)",
lType];
NSSet *filteredLicenses = [licenses filteredSetUsingPredicate:predicate];
If I change my predicate to use another attribute of SSSLicense, say name (instead of isArchived), the predicate works. I even added a simple boolean attribute to SSSLicense and filtered using it successfully.
It seems like it has something to do with the fact that isArchived is an attribute of the abstract entity. Is there something special I need to do to filter with inherited attributes?
Thanks!
NSPredicate
is not aNSString
, you need to learn more about how you should use the%K
and%@
format-specifiers for the predicates, or you can create a predicate with blocks which would be much more comfortable. – holex