对我而言,我使用这种方法连接互联网服务,主要问题是当我去另一个故事板时,方法dispatch_get_global_queue不会停止,当我去的时候我怎么能阻止它另一个故事板
let priority = DISPATCH_QUEUE_PRIORITY_DEFAULT
dispatch_async(dispatch_get_global_queue(priority, 0)) {
link = "http://nepraswebsite.com/new_lille/mobile_api/Products_list/index/BestView/1"
if let url = NSURL(string: "http://nepraswebsite.com/new_lille/mobile_api/Products_list/index/BestView/1") {
if let data = try? NSData(contentsOfURL: url, options: []) {
SearchResult = JSON(data: data)
}
}
self.didFinishLoadingSearch = true
}
dispatch_async(dispatch_get_main_queue()) {
HUD.show(.Progress)
}