Accessing iCloud photos uniquely on multiple devices using PHAsset

二次信任 提交于 2019-12-07 11:14:47

问题


Is there a way of accessing a specific PHAsset in an iCloud album uniquely on multiple devices?

I have written a simple app that lists thumbnails and .localIdentifiers from an iCloud shared album, and (naturally) it shows the same images on different devices, however, the localIdentifiers are different for the same images on different devices (not so unexpected as it is a "local" identifier).

However, what I actually want to do is associate a record in a cloud-shared CoreData database with an image in the cloud, rather than embed the image in the CoreData (it's a genealogy app, with potentially thousands of images) - for this I would need an identifier that is unique regardless of the device. Is there anyway to do this?


回答1:


Unfortunately not. In the early iOS 8 betas there was a cloud-identifier (which is exactly what you look for), but it was removed later on from the Photos API.




回答2:


PHAsset.cloudIdentifier is available as private API.

let identifier = phAsset.value(forKey: "cloudIdentifier") as? String

Refer to iOS runtime header: https://github.com/JaviSoto/iOS10-Runtime-Headers/blob/master/Frameworks/Photos.framework/PHAsset.h



来源:https://stackoverflow.com/questions/35083654/accessing-icloud-photos-uniquely-on-multiple-devices-using-phasset

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!