In the NSFetchedResultsController
for a tableview, I am trying to filter out cases where an attribute is true, 1, yes, on or whatever.
I am unclear on whether the NSPredicate
is not acting as it should because of 1) how my syntax handles nil
or null
values or 2) because it is not correct for the type of attribute.
In the xcdatamodeld file, the attribute is set to Boolean.
In the NSManagedObject
class, I have used an NSNumber
property--because to my knowledge, there is no Boolean property and one is supposed to substitute NSNumber.
@property (nonatomic, strong) NSNumber *isprivate;//boolean in model.
In some cases I have set the value to @1. However, in other cases it should be set to nil, though when I log it out it shows as null. I want to exclude from a fetch cases where the value of isprivate is true, yes, @1 or whatever.
My NSPredicate code is:
NSNumber *privVal = @1;
NSPredicate *securePred = [NSPredicate predicateWithFormat:@"isprivate!= %@",privVal];
which logs to console as isprivate != 1
However, it is not working as desired. Rather than filter out cases where isprivate is 1, it filters everything and returns no results.
So maybe it is interpreting nil or null values wrong.
The second possibility is that the syntax is wrong for Boolean/NSNumbers or whatever.
Would appreciate any suggestions on how to filter out nsmanagedobjects where a Boolean value set as above is True.
Thanks in advance for any suggestions.