Swfit 2 “Extra argument 'error' in call”

后端 未结 2 1402
面向向阳花
面向向阳花 2020-12-20 10:53

I\'ve been having a problem understanding what xcode wants from me when it gives me the \"Extra argument \'error\' in call\" it keeps pointing to

if let fee         


        
相关标签:
2条回答
  • 2020-12-20 11:02

    The way to do this in Swift 2 is

    let feed = try NSJSONSerialization.JSONObjectWithData(data!, options: .MutableContainers)
    
    0 讨论(0)
  • 2020-12-20 11:14

    Here is the new way of error handling in swift 2...

    do {
         if let feed = try NSJSONSerialization.JSONObjectWithData(data, options: .MutableContainers) as? NSDictionary {
          // Success block...
       }
    } catch {
        print(error)
    }
    
    0 讨论(0)
提交回复
热议问题