import UIKit
func calculatorFromString(colculation:String)->Double{
let mathExpression = try NSExpression(format: colculation)
let mathValue = mathExpression.expressionValue(with: nil, context: nil) as? Double
return mathValue!
}
calculatorFromString(colculation: "5*(1+4)")
当我将 colculation 设置为“5*(1+4)))”时,这是一个错误,我不知道如何捕获异常。谢谢!