The context type "NSFastEnumeration" cannot be used with an array literal

Swift 3, would you do that?

let changeRequest = PHAssetCollectionChangeRequest(...) let fastEnumeration = NSArray(array: [PHObjectPlaceholder]) albumChangeRequest?.addAssets(fastEnumeration) 

or that?

 let changeRequest = PHAssetCollectionChangeRequest(...) albumChangeRequest?.addAssets([PHObjectPlaceholder] as NSFastEnumeration) 

and what is the difference?

+6
source share
1 answer

As you have already found (your code has some inconsistency and causes other errors, it is better to update it), you cannot use as -casting to indicate the type of Array literals as NSFastEnumeration .

You need to find the correct class that matches NSFastEnumeration , in your case it is NSArray .

Usually write something like this:

 changeRequest?.addAssets([/* needs instances, not type...*/] as NSArray) 
+7
source

All Articles