ios - Why the Alamofire return early? -
alamofire.request(.get, gaode, parameters: ["location": location,"key":key]) .responsejson { response in guard response.response?.statuscode == 200 else{ return } js = json(response.result.value!) guard js["infocode"].string! == "10000" else { return } print("json: \(js)") guard js["regeocode"]["formatted_address"].string != nil else{ return } print(js["regeocode"]["formatted_address"].string) } return js["regeocode"]["formatted_address"].string!
the code execute return js["regeocode"]["formatted_address"].string!
before response. why?i want json before return. how solve problem?
the return outside response block, being returned totally separately network request.
Comments
Post a Comment