【发布时间】:2017-07-07 12:27:45
【问题描述】:
我有以下 swift3 代码:
var tempNames = ["Alan","Dan","Mark","Jack","Kelly","Andrew","Paul"]
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "LabelCell", for: indexPath)
let tempName = tempNames[indexPath.row]
cell.textLabel?.text = tempName
cell.detailTextLabel?.text = "Score"
return cell
}
这会产生以下内容:
如您所见,名称是静态的,而分数就是“分数”一词。以下 JSON 从返回 "https://str8red.com/jsonoverallleaderboard/":
[["shanu", "1056"], ["snookro", "828"], ["tingeypa", "709"], ["shaun", "620"], ["chrakers", "506"]]
我想做的是使用上面 JSON 中的名称和分数,而不是已经在使用的静态名称和分数。
我查看了 * 并遵循了一些指南,但没有成功。艾伦,对此的任何帮助将不胜感激。
【问题讨论】:
-
非常感谢 Vadian,我已经看到了这个链接,但是在实践中很难应用这个理论。