2021年4月1日星期四

Switch must be exhaustive / Cannot find 'JSON' in scope

guys! Once again my app is crashing and I don't have a clue to what to do. Does anyone could help out?! By the way, I'm beginner.. I'm learning. Please, be kind.

AF.request(URL_USER_ADD, method: .post, parameters: body, encoding: JSONEncoding.default, headers: header).responseJSON { (response) in

        switch response.result {                case .success(let result):                   if let json = result as? Data {                      guard let data = response.data else { return }                      let json = JSON(data: data)                      let id = json["_id"].stringValue                      let color = json["avatarColor"].stringValue                      let avatarName = json["avatarName"].stringValue                      let email = json["email"].stringValue                      let name = json["name"].stringValue                                            UserDataService.instance.setUserData(id: id, color: color, avatarName: avatarName, email: email, name: name)                      completion(true)                                      } else {                      completion(false)                      debugPrint(response.result as Any)  

Check it out the image of the error!

Thanks!

enter image description here

https://stackoverflow.com/questions/66912984/switch-must-be-exhaustive-cannot-find-json-in-scope April 02, 2021 at 08:11AM

没有评论:

发表评论