Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHObject localIdentifier reliability

Are there ever circumstances where the localIdentifier could change or not be accurate? I'm working on an application that backs up photos and have been told by my colleagues that the localIdentifier can't be trusted. However, after doing some research I have been unable to find anyone talking about this.

like image 733
Richmond Watkins Avatar asked Oct 17 '16 20:10

Richmond Watkins


2 Answers

LocalIdentifiers sometimes change after updating the iOS version.

I've seen the PHAsset.localIdentifiers (Photo API) change after iOS updates twice - in my own Apps. The last time was after updating to iOS 11. The app in question kept track of localIdentifiers so specific images could be found/sorted according to various predicates.

As soon as the update from iOS10 to 11 finished, all the localIdentifiers saved locally by the app became useless as they didn't match any device images, although they still existed in the camera roll.

Like you I've searched for info on this subject without success. Sorry that my reply is bad news.

like image 112
otaviokz Avatar answered Oct 05 '22 23:10

otaviokz


Use PHCloudIdentifier everywhere. You can use myCloudIdentifier.stringValue if you need it for data storage purposes.

Use cloudIdentifiers(forLocalIdentifiers:) method to convert from local to cloud and the sister method, localIdentifiers(for: [PHCloudIdentifier]), to convert back again.

like image 44
Stickley Avatar answered Oct 06 '22 00:10

Stickley