teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

1

追記

2019/09/04 04:18

投稿

unhappychoice
unhappychoice

スコア1531

answer CHANGED
@@ -7,7 +7,13 @@
7
7
  indexPaths = tableView.indexPathsForSelectedRows
8
8
  indexPaths.forEach { indexPath in
9
9
  // indexPath.section, indexPath.row から twoDimArray の対応する物を探す
10
+ let name = twoDimArray[indexPath.section][indexPath.row]
11
+ var price: Int
10
- // 対応から値段取得 例えば let price = Book[name]
12
+ if indexPath.section == 0 { // 対応から値段取得 Book section だった場合
13
+ price = Book[name]
14
+ } else if indexPath.section == 1 {
15
+ //...
16
+ }
11
17
  // 合計値を出したければ、セクションごとの合計用の変数を用意しておいて足していく
12
18
  }
13
19
  }