Convert a string with mathematical expressions into a float

前端 未结 4 967
隐瞒了意图╮
隐瞒了意图╮ 2021-01-16 17:39

A text field contains mathematical expressions like: 12+45-6 Is possible to convert this string to a number?

Can we use the predicate facility?

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-16 18:04

    Yes. Read up on "expression evaluation", or use a ready-made script interpreter. JavaScript is available to all iOS programs as a part of WebView.

提交回复
热议问题