UIImage for PHAsset

I am trying to convert UIImageto PHAssetbut could not find any solution. All I found is the other way around (i.e., From PHAssetto UIImage).

Scenario: I get images from a user directory in PHAssetCollectionand shown in UICollectionView. I also want to include several images from the previous screen that come from a remote source. I do not want to save deleted images in my directory, but I want to include them in my UICollectionView.

Please offer me a solution or a good alternative, so that the source UICollectionViewis the same (i.e. PHAssetCollection)

+4
source share
1 answer

You do not want to convert PHAssetto UIImage. I do not know if this is possible; it should not be, because PHAssetthey UIImagehave different properties, behavior, etc. Conversely, all properties UIImagecan be obtained from PHAsset, but not vice versa.

Instead, change the data source in the collection view to [UIImage], and instead change PHAssetto UIImage. This approach is clean and solves another problem: convert UIImageto PHImage.

+1
source

All Articles