【发布时间】:2017-11-04 12:12:46
【问题描述】:
我正在尝试从字典数组中填充 UITableVIew。这是我的 tableView / cellForRowAt 方法。 myPosts 是数组,里面有字典。当我使用 [indexPath.row] 时,它会将类型更改为“Any”并且不能将其转换为 dict。 我的问题是如何使用 indexPath 访问字典键的值?
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! CustomCell
let activePosts = myPosts[indexPath.row]
print(activePosts)
cell.customCellUsername.text = myUser
cell.customCellPost.text =
cell.customCellImage.image =
cell.customCellUserImage.image =
return cell
}
【问题讨论】:
标签: ios arrays swift uitableview dictionary