3
votes

I get the Asset Library URL for a photo using the UIImagePickerControllerReferenceURL key on the info dictionary obtained from UIImagePickerController. The url looks like this:

assets-library://asset/asset.JPG?id=1000000002&ext=JPG

Is this URL stable? Can I expect to save it in a document and then at a later date fetch the photo using this URL?

I basically have a iOS photo editing app where I allow the user to do some editing on a bunch of photos. I allow the user to save the project and edit at a later date. I would save these URLs to save the information about which photos are used in the project. I don't want to copy and save all the photos used in a project since there can be many photos used in a project and this will result in unnecessary duplication.

Can you also suggest if there is a better way around.

1

1 Answers

2
votes

Asset URLs are supposed to be stable but the format changed between iOS3 and iOS4 and the format in iOS5 is something like '/asset/FA8F1400-82A5-424F-A98C-2883754FA54D.jpg'. You shouldn't store asset URLs and expect them to remain valid forever, which is a shame because that is exactly what you would expect.

You could protect yourself by storing the asset's date and maybe location if it is set. Then if your app needs to, it can go through the asset library and patch up the references if the URL format changes again.