回答編集履歴
3
修正
test
CHANGED
@@ -53,3 +53,43 @@
|
|
53
53
|
}
|
54
54
|
|
55
55
|
```
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
---
|
60
|
+
|
61
|
+
`TextField`に入力した文字列と同じsectionを削除する場合以下の様に書いてください。
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
```swift
|
66
|
+
|
67
|
+
@IBAction func deleteSection(_ sender: UIButton) {
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
guard let text = textField.text,
|
72
|
+
|
73
|
+
!text.isEmpty,
|
74
|
+
|
75
|
+
!sectionTitleArray.isEmpty,
|
76
|
+
|
77
|
+
let indext = sectionTitleArray.index(of: text) else {
|
78
|
+
|
79
|
+
return
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
sectionTitleArray.remove(at: indext)
|
86
|
+
|
87
|
+
dataArrayGroup.remove(at: indext)
|
88
|
+
|
89
|
+
tableView.deleteSections(IndexSet(integer: indext), with: .automatic)
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
```
|
2
修正
test
CHANGED
@@ -17,3 +17,39 @@
|
|
17
17
|
}
|
18
18
|
|
19
19
|
```
|
20
|
+
|
21
|
+
---
|
22
|
+
|
23
|
+
`section`の削除
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
ボタンを何処かに追加して以下のメソッドとひも付けてください。
|
28
|
+
|
29
|
+
※とりあえず決め打ちで0番目の`section`を削除しています。
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
```swift
|
34
|
+
|
35
|
+
@IBAction func deleteSection(_ sender: UIButton) {
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
if sectionTitleArray.isEmpty {
|
40
|
+
|
41
|
+
return
|
42
|
+
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
sectionTitleArray.remove(at: 0)
|
48
|
+
|
49
|
+
dataArrayGroup.remove(at: 0)
|
50
|
+
|
51
|
+
tableView.deleteSections(IndexSet(integer: 0), with: .automatic)
|
52
|
+
|
53
|
+
}
|
54
|
+
|
55
|
+
```
|
1
修正
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
以下の部分のみ書き換える事で
|
1
|
+
`row`の削除に関しては以下の部分のみ書き換える事でできますよ。
|
2
2
|
|
3
3
|
|
4
4
|
|