swiftでtableViewの勉強をしています。
削除ボタンが押された時の下記コードの「editingStyle == UITableViewCell.EditingStyle.delete」の部分がいまいち理解できません。
// 追加:セルの削除機能 func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) { // .deleteのみでも可 if editingStyle == UITableViewCell.EditingStyle.delete { print(todoList) // データ削除 todoList.remove(at: indexPath.row) // それに対応するセルの削除 tableView.deleteRows(at: [indexPath as IndexPath], with: UITableView.RowAnimation.automatic) userDefaults.set(todoList, forKey: "todoList") } }
UITableViewCell.EditingStyle.deleteとは、そもそも何を表すものなのでしょうか(調べてみましたが、ピンとくる記事がありませんでした、)
また、editingStyle == UITableViewCell.EditingStyle.delete」とありますが、削除ボタンが押された時に、どのようなデータとどのようなデータを比較しているのでしょうか。
ご教示のほど何卒お願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/05/26 14:26