Catching NSInvalidArgumentException from NSExpression

后端 未结 2 489
南旧
南旧 2021-01-22 15:21

In my code I am evaluating strings as mathematical expressions for example:

NSString *formula=@\"9*7\";
NSExpression *expr =[NSExpression expressionWithFormat:fo         


        
2条回答
  •  天涯浪人
    2021-01-22 16:15

    What you need is a maths parser. NSExpression was designed to take well-formed input, and doesn't handle errors. A quick Google will give this.

提交回复
热议问题