I'm trying to implement function that saves captured photo to custom album following this article.
But I encountered error in this line (see article and Apple sample code):
albumChangeRequest!.addAssets([assetPlaceholder])
Contextual type of NSFastEnumeration cannot be used as Array Literal
This is happening because signature of addAssets
is:
func addAssets(_ assets: NSFastEnumeration)
What that means is that it expects collection that conforms to NSFastEnumeration
of which Swift Array
does not, but NSArray
does. Thus, creating NSArray
from your array of PHObjectPlaceholder
object works fine.
let fastEnumeration = NSArray(array: [photo.placeholderForCreatedAsset!] as [PHObjectPlaceholder])
albumChangeRequest!.addAssets(fastEnumeration)
This should work with Swift 3
albumChangeRequest.addAssets([photoPlaceholder] as NSArray)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With