【问题标题】:Cannot invoke 'enumerateObjects' with an argument list of type '((AnyObject!, NSInteger, UnsafeMutablePointer<ObjCBool>) -> ())'无法使用类型为“((AnyObject!,NSInteger,UnsafeMutablePointer<ObjCBool​​>)->())”的参数列表调用“enumerateObjects”
【发布时间】:2016-09-20 10:19:20
【问题描述】:

我的项目在 Xcode 8 的这一行中遇到错误,而它在 Xcode 7 中运行良好。

(self.columnHeights[section] as AnyObject).enumerateObjects({(object : AnyObject!, idx : NSInteger,pointer :UnsafeMutablePointer<ObjCBool>) 

错误

 Cannot invoke 'enumerateObjects' with an argument list of type '((AnyObject!, NSInteger, UnsafeMutablePointer<ObjCBool>) -> ())'

请指教。

【问题讨论】:

    标签: ios iphone swift swift3


    【解决方案1】:

    在 Swift 3 中,大多数 AnyObject 类型已更改为 Any

    (self.columnHeights[section] as AnyObject).enumerateObjects({(object : Any, idx : Int, pointer :UnsafeMutablePointer<ObjCBool>) 
    

    一如既往,我建议使用原生 Swift Array 而不是 Foundation NSArray 来利用特定类型信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-31
      • 2015-08-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多