Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let testValue = 10
- let formula = "(max(testValue - 20,0) * 14) + testValue - max(testValue - 20,0)"
- //Current way
- extension String {
- var expression: NSExpression {
- return NSExpression(format: self)
- }
- }
- let results = formula.expression.expressionValue(with: nil, context: nil) as? Int
Add Comment
Please, Sign In to add comment