Reputation: 12367
I searched the whole internet but could not find any good explanation on how to use NSExpression in NSPredicate. I know that there's built in function abs which I need for my predicate. I have this predicate:
NSPredicate *predicate=[NSPredicate predicateWithFormat:@"hg-%f<0.000001",[txtInput.text floatValue]];
I need absolute value of hg-[txtInput.text floatValue] part. How do I achieve it?
Upvotes: 0
Views: 1923
Reputation: 56625
Add abs( )
around the expression you want the absolute value of inside your predicate string
NSPredicate *predicate=[NSPredicate predicateWithFormat:@"abs(hg-%f)<0.000001",[txtInput.text floatValue]];
Upvotes: 4