NSPredicate issue with greater than equals
ios, nspredicate, objective-c
Solution
I assume that your property is stored as string and not as number, therefore the values are compared as strings:
"10000" < "250" < "6000"
Using `NSNumber` instead of `NSString` (or alternatively some scalar type as `NSInteger`) should fix the problem.
If you cannot change the data type of the `squareFootage` property, then the following predicate should work:
[NSPredicate predicateWithFormat:@"SELF.data.squareFootage.intValue >= %d", [filterSquareFootage intValue]]
Problem
I have a simple NSPredicate which is not giving correct result ``` NSPredicate *resultPredicate = [NSPredicate predicateWithFormat:@"SELF.data.squareFootage >= %@", filterSquareFootage]; filteredArray = [[filteredArray filteredArrayUsingPredicate:resultPredicate] mutableCopy]; ``` Strangely this works for all 6000>=250, 7000>=250, 8000>=6000. But as soon as squareFootage==10000 the predicate for 10000>=any smaller value is false. Note: 10000 for squareFootage is a max value fetched using a UISlider.If i reduce value to any smaller value, the predicate gives true as result Am i missing something here and using predicate incorrectly?