ios - 对成员 'count' 的模糊引用

标签 ios arrays xcode swift swift2

当我将当前的 Xcode (v 7.0.1) 项目迁移到 Xcode 7.1.1 时出现以下错误

  • 对成员“计数”的引用不明确
  • 不能下标“数组”类型的值

知道如何解决上述错误吗?

我的代码如下

  var arrOfRewardDetail : Array = [Dictionary<String, String>]()
  func tableView(tableView: UITableView, numberOfRowsInSection section: Int) ->  Int {
    return arrOfRewardDetail.count //Ambiguous reference to member 'count'
}

 if self.arrOfRewardDetail[indexPath.row]["KEY"] == "Promotion By : "{} // Cannot subscript a value of type 'Array'

更新 现在出现以下错误

  • 对成员“indexOf”的引用不明确 let indexOfEnum : Int = self.arrPromitionDetailEnum.indexOf(dictRewardInfo["r_promotion_detail_type"]!)!
  • 还有这个 let indexOfEnum : Int = self.arrPromitionDetailEnum.indexOf(dictInfo["r_promotion_detail_type"]!)!//不能下标 'Array' 类型的值

最佳答案

只需删除 : Array部分:

var arrOfRewardDetail = [Dictionary<String, String>]()

编译器会推断出正确的类型,即[Dictionary<String, String>] ,不只是 Array .

关于ios - 对成员 'count' 的模糊引用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34066079/

相关文章:

ios - 在 iOS SDK 上,有没有办法以编程方式连接到特定的蓝牙 PAN?

android - 如何在 React Native iOS 中对图像进行透明渐变?

ios - 数组不断返回空值

C Turtle 图形不需要的数组输出

objective-c - 检查并从没有索引的 nsmutable 数组中删除特定字符串

ios - 如何在tableview cell swift 3.0中设置选中的复选标记

iphone - 点击导航后退按钮时会调用什么方法-IOS?

ios - 展开/折叠 UITableView 中的单元格数组

ios - 如何删除另一次点击的复选标记?

javascript - 循环数据集 ChartJS Javascript