Imran
Imran

Reputation: 779

PHAssetCollectionChangeRequest: addAssets() now accepts NSFastEnumeration. how to achieve this?

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?

Upvotes: 7

Views: 3266

Answers (1)

sudo make install
sudo make install

Reputation: 5669

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)

Upvotes: 17

Related Questions