I have a NSString object having multiple conditions specified in it like below:
NSString *strFormula1 = @"\"man\" == \"man\" && 1<5 || 12<9";
NSString *strFormula2 = @"\"pac@pac.com\" == \"pac1@pac1.com\" || 9==9 && 8>2 || 2==2";
I want to execute formula specified in the NSString object & find out the answer as BOOL.
Whether the condition specified is returning True or False.
Thanks in advance:)
Just use an
NSPredicatelike this:And if you’re curious to see how the predicate parsed your expression just use:
Which in our case returns: