Xcodeエラー:呼び出しはスローできますが、「try」のマークがなく、エラーは処理されません



Xcode Error Call Can Throw



Execution code let user = [ 'uname': 'Zhang San', 'tel': ['mobile': '138', 'home': '010'] ] let data : NSData! = NSJSONSerialization.dataWithJSONObject(user, options: nil, error: nil) let json : AnyObject! = NSJSONSerialization .JSONObjectWithData(data, options:NSJSONReadingOptions.AllowFragments, error:nil) Error message Call can throw, but it is not marked with 'try' and the error is not handled Extra argument ‘error’ in call Modified code let data : NSData! = try? NSJSONSerialization.dataWithJSONObject(user, options: []) let json : AnyObject! = try? NSJSONSerialization .JSONObjectWithData(data, options:NSJSONReadingOptions.AllowFragments)

転載:https://www.jianshu.com/p/8c3b69dc9317