2017-04-07 9 views
1
let dict_one=result[i] 

    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="" 
    } 

私は迅速にバックグラウンドでディスパッチキューを使用する必要があります。3.1解決方法を見つけることができますか?ここでSwiftのバックグラウンドで優先度が高いディスパッチキューの使い方3.1

答えて

0

あなたが行く:

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) 
    } 
} 

・ホープ、このことができますし。

+0

このコードは、UIブロック –

+0

の問題を作成します。いいえ、ここでコードを実行してメインスレッドに戻ります。メインキューに戻るための回答が更新されました。 –

+0

私は理解していない、何を言っている –

関連する問題