Last active
October 23, 2019 04:45
-
-
Save TonSDe/9414cb38489c3d3004df29dca1a21319 to your computer and use it in GitHub Desktop.
DispatchQueue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ตัวอย่างการทำงานของ Task | |
var ID:string = nil | |
func getDataFromURL() { | |
let URL:string = "https://xxx...." | |
Alamofire.request(URL, method: .get, parameters: nil).responseJSON { response in | |
let dataJSON = JSON(response.result.value!) | |
if let id:String = dataJSON["data"]["id"].string { | |
self.ID = id | |
} | |
} | |
self.checkData() | |
} | |
func checkData() { | |
if self.ID == nil { | |
print("ID = Nil") | |
} else { | |
print("ID != Nil") | |
} | |
} | |
// Run Function | |
self.getDataFromURL() //OUTPUT = ID = Nil |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment