回答編集履歴
1
追記
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
|
-
// 対応から値段取得
|
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
|
}
|