Cannot call "map" using argument list of type "([AnyObject], (_) & # 8594; _) '

I write one method in swift 1 as follows:

public var array: [JSON]? {
     get {
         if self.type == .Array {
             return map(self.object as! [AnyObject]){ JSON($0) }
         } else {
             return nil
         }
     }
}

when I install Xcode 7.2 (swift 2), this method gives me this error:

It is not possible to call "map" using a list of arguments of the type "([AnyObject], (_) → _) '

Now I want to know what this problem is?

+4
source share
1 answer

Do not force push and call mapin array as function was moved in Swift 2

return (self.object as? [AnyObject])?.map{ JSON($0) }
+2
source

Source: https://habr.com/ru/post/1623037/


All Articles