2

我将公式存储1 && !0 && (0 || 1)NSString变量中。我需要将此字符串评估为单个布尔值。有谁知道用于处理此或第 3 方解决方案的内置 obj-c 对象?

提前致谢。

4

2 回答 2

1

我认为[NSPredicate parseWithFormat:]并且[NSPredicate evaluateWithObject:]可以在这里提供帮助。

于 2013-02-06T18:25:13.320 回答
0

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.

于 2013-02-06T18:08:52.550 回答