0
我有一個應用程序,用戶可以下載pdf文件。我最近搬到alamofire 4,迅速3.我嘗試查看PDF文件下載完成之後,但它扔Realm accessed from incorrect thread.
下載完成後從不正確的線程訪問的領域Swift 3
這裏是我的代碼:
Alamofire.download(url, method: .get, encoding: JSONEncoding.default, to: destination)
.downloadProgress(queue: DispatchQueue.global(qos: .utility)) { progress in
DispatchQueue.main.async {
magazineObject.progressBarDownload = self.percentProgress
magazineObject.progressBarTitle = self.percentProgressNext.cleanValue
}
}
}
.validate { request, response, temporaryURL, destinationURL in
self.localPath = destinationURL
magazineObject.pathDatabase = String(describing: self.localPath!)
magazineObject.progressBarDownload = Double(self.percentProgressFinal)
magazineObject.progressBarTitle = Float(self.displayFinalLabelPercent).cleanValue
magazineObject.statusDarkViewAfterRelaunch = 1
magazineObject.statusDownload = self.statusDatabase
try! realm.write {
realm.add(magazineObject)
}
return .success
}
它可以查看詳細信息!萬分感謝! –