7

enter image description here

My Application tries to import an image from photos and adds to an album.

But in latest swift changes. addAssets() accepts parameter as NSFastEnumeration. So I get an error as shown in the image.

even the Apple API document has this same code: https://developer.apple.com/library/prerelease/ios/documentation/Photos/Reference/PHAssetChangeRequest_Class/index.html#//apple_ref/occ/instp/PHAssetChangeRequest/placeholderForCreatedAsset

What is the alternative or how do I addAssets now?

Imran
  • 769
  • 1
  • 9
  • 21

1 Answers1

16

So, I did some research, and according to NSHipster, NSEnumeration is a protocol implemented by NSArray, NSSet, and NSDictionary. This suggests that if you convert [assetPlaceholder] to an NSArray, you'll be able to use it in the method. And, in fact, this compiles:

let enumeration: NSArray = [assetPlaceholder!]
albumChangeRequest!.addAssets(enumeration)
sudo make install
  • 5,629
  • 3
  • 36
  • 48