質問編集履歴
3
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,13 +10,11 @@
|
|
10
10
|
|
11
11
|
swift3.0
|
12
12
|
|
13
|
-
import UIKit
|
14
|
-
|
15
|
-
i
|
13
|
+
class ViewController:UIViewController,UITextFieldDelegate,UITableViewDelegate{
|
16
14
|
|
17
15
|
|
18
16
|
|
19
|
-
|
17
|
+
|
20
18
|
|
21
19
|
var main:Main!
|
22
20
|
|
@@ -26,7 +24,9 @@
|
|
26
24
|
|
27
25
|
// weak var editingTextField:UITextField?
|
28
26
|
|
29
|
-
var numberList:[String] = []
|
27
|
+
var numberList:[String] = []
|
28
|
+
|
29
|
+
|
30
30
|
|
31
31
|
// 管理オブジェクトコンテキストの保存
|
32
32
|
|
@@ -60,6 +60,10 @@
|
|
60
60
|
|
61
61
|
|
62
62
|
|
63
|
+
// do {
|
64
|
+
|
65
|
+
//部活動登録用の管理オブジェクトコンテキストを取得する。
|
66
|
+
|
63
67
|
let applicationDelegate = UIApplication.shared.delegate as! AppDelegate
|
64
68
|
|
65
69
|
context = applicationDelegate.managedObjectContext
|
@@ -86,7 +90,9 @@
|
|
86
90
|
|
87
91
|
numberList.append(main.number!)
|
88
92
|
|
89
|
-
}
|
93
|
+
}
|
94
|
+
|
95
|
+
|
90
96
|
|
91
97
|
} catch {
|
92
98
|
|
@@ -94,7 +100,9 @@
|
|
94
100
|
|
95
101
|
}
|
96
102
|
|
97
|
-
print(numberList.count)
|
103
|
+
print("回数\(numberList.count)")
|
104
|
+
|
105
|
+
|
98
106
|
|
99
107
|
}
|
100
108
|
|
@@ -120,7 +128,9 @@
|
|
120
128
|
|
121
129
|
}
|
122
130
|
|
131
|
+
|
132
|
+
|
123
|
-
}
|
133
|
+
}
|
124
134
|
|
125
135
|
|
126
136
|
|
2
文法の修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,11 +6,17 @@
|
|
6
6
|
|
7
7
|
CoreDataにしっかり保存はできているのですが、データの要求がしっかりできていないのか、もしくはTableVIewCellに表示させるコードが間違っているのかが分かりません。どなたか、お願いいたします。
|
8
8
|
|
9
|
+
```
|
10
|
+
|
9
|
-
|
11
|
+
swift3.0
|
12
|
+
|
13
|
+
import UIKit
|
14
|
+
|
15
|
+
import CoreData
|
16
|
+
|
17
|
+
|
10
18
|
|
11
19
|
class ViewController:UIViewController,UITextFieldDelegate,UITableViewDelegate{
|
12
|
-
|
13
|
-
|
14
20
|
|
15
21
|
var main:Main!
|
16
22
|
|
@@ -18,9 +24,9 @@
|
|
18
24
|
|
19
25
|
var coreDataStack:CoreDataStack!
|
20
26
|
|
21
|
-
var n
|
27
|
+
// weak var editingTextField:UITextField?
|
22
28
|
|
23
|
-
|
29
|
+
var numberList:[String] = []
|
24
30
|
|
25
31
|
// 管理オブジェクトコンテキストの保存
|
26
32
|
|
@@ -52,11 +58,13 @@
|
|
52
58
|
|
53
59
|
super.viewDidLoad()
|
54
60
|
|
55
|
-
|
61
|
+
|
56
62
|
|
57
63
|
let applicationDelegate = UIApplication.shared.delegate as! AppDelegate
|
58
64
|
|
59
65
|
context = applicationDelegate.managedObjectContext
|
66
|
+
|
67
|
+
|
60
68
|
|
61
69
|
do {
|
62
70
|
|
@@ -70,7 +78,7 @@
|
|
70
78
|
|
71
79
|
let mainList = try context.fetch(fetchRequest) as! [Main]
|
72
80
|
|
73
|
-
dismiss(animated: true, completion: nil)
|
81
|
+
//dismiss(animated: true, completion: nil)
|
74
82
|
|
75
83
|
numberList = []
|
76
84
|
|
@@ -78,7 +86,7 @@
|
|
78
86
|
|
79
87
|
numberList.append(main.number!)
|
80
88
|
|
81
|
-
}
|
89
|
+
}
|
82
90
|
|
83
91
|
} catch {
|
84
92
|
|
@@ -86,7 +94,11 @@
|
|
86
94
|
|
87
95
|
}
|
88
96
|
|
97
|
+
print(numberList.count)
|
98
|
+
|
99
|
+
}
|
100
|
+
|
89
|
-
func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
|
101
|
+
private func tableView(_ tableView: UITableView, cellForRowAtIndexPath indexPath: IndexPath) -> UITableViewCell {
|
90
102
|
|
91
103
|
// let cell = UITableViewCell(style: UITableViewCellStyle.default, reuseIdentifier: "MainCell"
|
92
104
|
|
@@ -94,18 +106,22 @@
|
|
94
106
|
|
95
107
|
cell.numberLabel?.text = main.number
|
96
108
|
|
109
|
+
//cell.numberLabel?.text = numberList[indexPath.row]
|
110
|
+
|
97
111
|
return cell
|
98
112
|
|
99
113
|
}
|
100
114
|
|
101
|
-
}
|
102
115
|
|
116
|
+
|
103
|
-
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
117
|
+
private func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
104
118
|
|
105
119
|
return numberList.count
|
106
120
|
|
107
121
|
}
|
108
122
|
|
109
|
-
}
|
123
|
+
}
|
124
|
+
|
125
|
+
|
110
126
|
|
111
127
|
```
|
1
書式の変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -25,10 +25,6 @@
|
|
25
25
|
// 管理オブジェクトコンテキストの保存
|
26
26
|
|
27
27
|
func saveContext () throws {
|
28
|
-
|
29
|
-
// コンテキストに変更があるかを確認
|
30
|
-
|
31
|
-
// 保存処理はコンテキストに変更がある場合のみ行う
|
32
28
|
|
33
29
|
if context.hasChanges {
|
34
30
|
|