1
我會推送通知。如果數據庫中沒有數據,則在顯示之前下載。我使用Grand Central Dispatch
做了一段時間間隔,但它不是正確的,因爲例如用戶是一個弱的互聯網應用程序下降。如何在swift中執行屏障3
下載數據之前,如何延遲GCD屏障顯示數據?
此代碼的時間間隔:
if equal == false {
let url = "https://****.**/json/post/\(data)"
self.download.getLastestNews(url)
}
let when = DispatchTime.now() + 2
DispatchQueue.main.asyncAfter(deadline: when) {
let newsCategory = self.realm.objects(News.self).filter("newsID == \(self.id)")
vc.titleText = (newsCategory.first?.newsTitle)!
vc.fullText = (newsCategory.first?.newsFullText)!
vc.imageLink = (newsCategory.first?.newsImage)!
if let tabBarController = self.window?.rootViewController {
tabBarController.present(vc, animated: true, completion: nil)
}
}
平臺的iOS 9 *,iOS的3