nsexpression

Catch an exception for invalid user input in swift

天大地大妈咪最大 提交于 2019-11-26 08:34:55
问题 I am trying this code that is a calculator. How can I handle input from the user that is not valid? //ANSWER: Bridging header to Objective-C// https://github.com/kongtomorrow/TryCatchFinally-Swift Here is the same question but in objc but I want to do this in swift. Catching NSInvalidArgumentException from NSExpression All I want to show is a message if it doesn\'t work, but now I am getting an exception when the user doesn\'t input the correct format. import Foundation var equation:NSString