【发布时间】:2017-11-17 16:41:11
【问题描述】:
我想对用户的照片库做一些工作。由于图书馆可能很大,我想在后台进行。我想知道执行资产提取(如PHAsset.fetchAssets)并在后台处理它们是否安全?
我现在只需要资产元数据。
这样的东西安全吗:
class ViewController: UIViewController {
var cachedResult = [Any]()
func doBackgroundCalculationsOnPhotos(completionHandler: ([Any]) -> ()) {
DispatchQueue.global(qos: .userInitiated).async {
let photos = PHAsset.fetchAssets(with: .image, options: nil)
var result = [Any]()
photos.enumerateObjects({ asset, _, _ in
result.append(calculateSomething(asset))
})
DispatchQueue.main.async {
self.cachedResult = result
completionHandler(result)
}
}
}
}
是否有任何参考文档可以让我了解照片框架和后台访问?
【问题讨论】:
-
我也有同样的问题。
标签: ios swift multithreading photosframework