0

We have a very specific use case in the app I am working on where we need the following:

  1. Download PHAsset iCloud images and make sure data is cached on disk so next time it can be retrieved offline
  2. Create PHAsset from a file URL but do not show them in the Photos app
  3. Tie the PHAsset to the app, so if the app is deleted all PHAssets created by the app are removed with it

As far as I can tell from my investigation, there's no way we can do this.

Note: there's an internal library we are trying to avoid to modify that works only with PHAssets. However, we now need to support images downloaded from the internet to work with this library too, thus the need to generate our own PHAssets and the ability to manage those.

mdonati
  • 1,049
  • 11
  • 24

1 Answers1

0

This sounds like a misunderstanding of the term PHAsset. PHAssets are not something you manage. They are barely things at all. A PHAsset is not an image. It is nothing but a clump of information about a photo or video in the user's photo library.

So, if you load an image from a file URL, or download an image from the Internet, or whatever, that isn't a PHAsset.

You can save image data to disk, show the image or not, and so forth; and the image data on disk is tied to the app, because your app is sandboxed so that when it is deleted, all its data is deleted. But that has nothing to do with PHAssets; what PHAssets there are depends on what's in the library, and that's up to the user, with no relationship to your app.

matt
  • 515,959
  • 87
  • 875
  • 1,141