无法使用类型为“([AnyObject],(_) -> _)”的参数列表调用 'map'
Cannot invoke 'map' with an argument list of type '([AnyObject],(_) -> _)'
我在 swift 1 中这样写了一个方法:
public var array: [JSON]? {
get {
if self.type == .Array {
return map(self.object as! [AnyObject]){ JSON([=11=]) }
} else {
return nil
}
}
}
当我安装 Xcode 7.2 (swift 2) 时,此方法给我这样的错误:
无法使用类型为“([AnyObject],(_) -> _)”的参数列表调用 'map'
现在我想知道那个问题是什么?
不要使用强制转换,并在数组上调用 map
,因为函数已移至 Swift 2
return (self.object as? [AnyObject])?.map{ JSON([=10=]) }
我在 swift 1 中这样写了一个方法:
public var array: [JSON]? {
get {
if self.type == .Array {
return map(self.object as! [AnyObject]){ JSON([=11=]) }
} else {
return nil
}
}
}
当我安装 Xcode 7.2 (swift 2) 时,此方法给我这样的错误:
无法使用类型为“([AnyObject],(_) -> _)”的参数列表调用 'map'
现在我想知道那个问题是什么?
不要使用强制转换,并在数组上调用 map
,因为函数已移至 Swift 2
return (self.object as? [AnyObject])?.map{ JSON([=10=]) }