ios - Alamofire Async time in Swift3 -
i have complicate problem me, seems alamofire async problem, , tried find solution here, didn't.. can extract other information in photoasset(i used dkimagepickercontroller), image , creation date..etc. i'd reverse-geo coding using google api, that's why need use alamofire. imagelist return yes, dkassetlist yes, addresslist use alamofire return nil!! please me problem..
below code.
@iboutlet weak var imagecollectionview: uicollectionview! var imagelist:[uiimage] = [] var addresslist:[string]? var dkassetslist:[dkasset] = [] var locationinfo:[photolocationinfo] = [] var datelist:[date] = [] @ibaction func imagepickerbuttontouched(_ sender: uibutton) { let pickercontroller = dkimagepickercontroller() pickercontroller.didselectassets = {[unowned self](assets: [dkasset]) in asset in assets { self.dkassetslist.append(asset) print(self.dkassetslist) let assetlocation = asset.location?.coordinate let assetlongitude = assetlocation?.longitude ?? 33.3333 let assetlatitude = assetlocation?.latitude ?? 121.000 let urlstring = "https://maps.googleapis.com/maps/api/geocode/json?latlng=\(assetlatitude),\(assetlongitude)&key=aizasybakz-vm07x452ocvplbqcloth2askjpxe" alamofire.request(urlstring, method: .get, parameters: nil, encoding: jsonencoding.prettyprinted, headers: nil).responsejson(completionhandler: {[unowned self](response) in guard let data = response.result.value else {return} if response.result.issuccess { let mydata = json(data) print(mydata["results"][0]["formatted_address"].stringvalue) self.addresslist?.append(mydata["results"][0]["formatted_address"].stringvalue) self.imagecollectionview.reloaddata() print(self.addresslist) } })
Comments
Post a Comment