Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

swift

phasset

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?

like image 417
Imran Avatar asked Jun 13 '15 12:06

Imran


1 Answers

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)
like image 139
sudo make install Avatar answered Nov 16 '22 01:11

sudo make install