ios - 如何在 Swift 3.1 后台使用调度队列实现高优先级
<p><pre><code> let dict_one=result
let product:AllProducts=AllProducts()
product.applications=dict_one.objectForKey("applications") as? String
product.desc=dict_one.objectForKey("description") as? String
product.familyId=String(dict_one.objectForKey("familyId") as! Int)
if dict_one.objectForKey("imageName") as? String!= nil
{
product.imageName=dict_one.objectForKey("imageName") as? String
let url:String =AppConstant.GetAllImages + (dict_one.objectForKey("imageName") as? String)!
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0))
{
let imagePath=self.fileInDocumentsDirectory((dict_one.objectForKey("imageName") as? String)!)
self.saveImage(url, image_name1: (dict_one.objectForKey("imageName") as? String)!,path: imagePath)
}
}
else
{
product.imageName=""
}
</code></pre>
<p>我需要在 swift 3.1 的后台使用高优先级的调度队列,你能帮忙找出解决方案吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>给你:</p>
<pre><code>DispatchQueue.global(qos: .userInitiated).async {
//Your code goes here
//Coming back to the main queue to update the UI
DispatchQueue.main.async {
//Update your ui (reloading tableView, Label update, etc. here)
}
}
</code></pre>
<p>希望这对您有所帮助。</p></p>
<p style="font-size: 20px;">关于ios - 如何在 Swift 3.1 后台使用调度队列实现高优先级,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/43275524/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/43275524/
</a>
</p>
页:
[1]