I'm storing a formula 1 && !0 && (0 || 1)
in a NSString
variable. I need to evaluate this string to a single boolean. Does anyone know of a built in obj-c object for handling this or a 3rd party solution?
Thanks in advance.
I'm storing a formula 1 && !0 && (0 || 1)
in a NSString
variable. I need to evaluate this string to a single boolean. Does anyone know of a built in obj-c object for handling this or a 3rd party solution?
Thanks in advance.
I think [NSPredicate parseWithFormat:]
and [NSPredicate evaluateWithObject:]
could help here.
Short of parsing it yourself, you won't be able to evaluate an expression like that in Objective-C during runtime since it is not an interpreted language.
Here are just a few (of many) other resources that pretty much echo this:
This post may get you a step closer to what you are trying to achieve. In any scenario, you will have to parse it yourself.