Swiftを勉強し始めたので自分用メモ。インデントの修正ははめんどくさいのでそのまま。
table rowのサイズを宣言してあげる。
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return itemArray.count
}
```
ellの値を決めてあげる
```
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "ToDoItemCell", for: indexPath)
cell.textLabel?.text = itemArray[indexPath.row]
return cell
}
```
`tableView`はswiftのbuilt-in functionなのでoverrideが必用という認識。
選択したRowでイベントを発火させるとき。
```
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
print(itemArray[indexPath.row])
}
```
tap gesture使ってた・・
選択したrowにアクセサリーで飾りをつけてあげる
`tableView.cellForRow(at: indexPath)?.accessoryType = .checkmark`