我怎么能从运行中取消DISPATCH_QUEUE_PRIORITY_DEFAULT

时间:2016-03-20 00:01:18

标签: swift grand-central-dispatch

对我而言,我使用这种方法连接互联网服务,主要问题是当我去另一个故事板时,方法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)
        }

0 个答案:

没有答案