0

I met the following compile error:

Cannot invoke 'enumerateObjectsUsingBlock' with an argument list of type '((_, _, _) -> Void)'

I think it may be easier to understand my situation with this screenshot of XCode6.3.

enter image description here

This codes is for testing the fetching of PHAsset objects using the fetchAssetsWithMediaType method. As you may know, this method returns PHFetchResult which has enumeration methods. I tried to enumerate all object in the result by enumerateObjectsUsingBlock. Unfortunately, the Swift compiler gave me an error. After a long investigation, I ended up making a conclusion that this code is correct.

For your information, the above code is found by googling for testing PHAsset.

ChristopheD
  • 112,638
  • 29
  • 165
  • 179
Kyokook Hwang
  • 2,682
  • 21
  • 36

1 Answers1

1

I finally found the answer to my question. a first parameter of a block of enumerateObjectsUsingBlock is AnyType!. Therefore, obj argument for append method should be downcast with as!.

Anyway, I think an error message is not exact to point out this mistake. It seems that the compiler give this kind of an error message to a programmer when something wrong is in a block.

Kyokook Hwang
  • 2,682
  • 21
  • 36