2017-08-17 45 views
1

我有一個應用程序,與舊的swift代碼開發。現在我將它更新爲最新的swift語法。雖然更新我發現在調度隊列困難,在這裏它給兩個警告全球(優先級)在IOS 8已被廢棄和背景在IOS 8優先和背景已被棄用在ios 8

DispatchQueue.global(priority: DispatchQueue.GlobalQueuePriority.background).async(execute: { [weak self] in  //Getting warning in this line 
    if let strongSelf = self { 
     strongSelf.populateOutBoundContacts() 
     strongSelf.lookForContactsToPresent() 
    } 
}) 
+1

https://stackoverflow.com/a/37806522/5362750看起來這個 –

回答

1

的語法變更爲DispatchQueue.global(qos: DispatchQoS.QoSClass)棄用。您不需要撥打async(execute),您可以直接撥打async並在封閉處編寫要執行的代碼。

DispatchQueue.global(qos: .background).async{ [weak self] in  
    if let strongSelf = self { 
     strongSelf.populateOutBoundContacts() 
     strongSelf.lookForContactsToPresent() 
    }   
} 

在更新舊的代碼,我強烈建議要通過相應類別的文檔,並使用Xcode的自動完成功能,它可以尋找新的語法/方法時,爲您節省大量的時間。

+0

謝謝你它對我有用...... – MIOSY

+0

很高興我能幫到你。如果您發現我的答案有用,請考慮接受它。 –