0
テーブルビューの行の内容を辞書で定義していますが、追加しようとすると混乱します私は誤りです。Xcodeエラー: '値に代入できません:関数呼び出しは不変の値を返します'
var places = [[String: Any]]()
class TableViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
if places.count == 0 {
places.append(["name":"Taj Mahal", "lat": "27.175277", "lon": "78.042128"])
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
cell.textLabel?.text = places[indexPath.row]["name"]
return cell
}
エラーは、私が定義する部分である:
cell.textlabel?.text = places[indexPath.row]["name"]
thiscell.textLabelを試してください?.text = [indexPath.row] ["name"]を!文字列 –