Guest User

Untitled

a guest
Nov 19th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. let testValue = 10
  2. let formula = "(max(testValue - 20,0) * 14) + testValue - max(testValue - 20,0)"
  3.  
  4. //Current way
  5. extension String {
  6. var expression: NSExpression {
  7. return NSExpression(format: self)
  8. }
  9. }
  10.  
  11. let results = formula.expression.expressionValue(with: nil, context: nil) as? Int
Add Comment
Please, Sign In to add comment