Search code examples
iosarraysswiftuiimagepickercontrollerphasset

How do you use a button click function to convert an [PHAsset] to PHAsset in Swift


public func nohanaImagePicker(_ picker: NohanaImagePickerController, didFinishPickingPhotoKitAssets pickedAssts: [PHAsset])
{
    print("🐷Completed🙆\n\tpickedAssets = \(pickedAssts)")
    self.getAssetThumbnail(asset: pickedAssts)
    picker.dismiss(animated: true, completion: nil)
    self.ImageCollectionView.reloadData()
}

Anyone can u explain how to convert the [PHAsset] value to PHAsset


Solution

  • [PHAsset] is an array of PHAsset objects. You can pick the first object of the array like this.

    let phAsset = pickedAssts.first