質問編集履歴

2

わかりやすく変更

2019/01/11 01:02

投稿

hahum
hahum

スコア65

test CHANGED
File without changes
test CHANGED
@@ -114,7 +114,7 @@
114
114
 
115
115
 
116
116
 
117
- 追記
117
+ 追記 1/11
118
118
 
119
119
 
120
120
 

1

hennkou

2019/01/11 01:02

投稿

hahum
hahum

スコア65

test CHANGED
File without changes
test CHANGED
@@ -111,3 +111,197 @@
111
111
 
112
112
 
113
113
  ```
114
+
115
+
116
+
117
+ 追記
118
+
119
+
120
+
121
+ 新しいエラーが次の画面であるTableViewに出ています。(Sigabrt)
122
+
123
+ 前回同様部品の紐付けは確認いたしました。エラーメッセージは前回同様Could not cast value of type 'NSTaggedPointerString' to 'NSArray' .です。
124
+
125
+
126
+
127
+ SaveViewContoroller.swift
128
+
129
+ ```swift
130
+
131
+ var resultArray2 = [String]()
132
+
133
+
134
+
135
+ var dateArray2 = [String]()
136
+
137
+
138
+
139
+ var Array2: [[String]] = []
140
+
141
+ ...
142
+
143
+ ...
144
+
145
+ ...
146
+
147
+
148
+
149
+
150
+
151
+ override func viewDidLoad() {
152
+
153
+ super.viewDidLoad()
154
+
155
+
156
+
157
+
158
+
159
+ tableView.delegate = self
160
+
161
+ tableView.dataSource = self
162
+
163
+
164
+
165
+ if UserDefaults.standard.object(forKey: "save") != nil {
166
+
167
+
168
+
169
+ Array2 = [UserDefaults.standard.object(forKey: "save") as! [String]]
170
+
171
+ }
172
+
173
+
174
+
175
+ Array2 = [resultArray2, dateArray2]
176
+
177
+
178
+
179
+
180
+
181
+ self.resultArray2 = self.Array2[0]
182
+
183
+ self.dateArray2 = self.Array2[1]
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+ //Array2 = [ ["晴れ", "雨", "雪"],
194
+
195
+ //["2019/1/1", "2019/1/2", "2019/1/3"] ]
196
+
197
+
198
+
199
+ print("Array2:", Array2.description)
200
+
201
+ print(resultArray2.description)
202
+
203
+ print(dateArray2.description)
204
+
205
+
206
+
207
+ }
208
+
209
+
210
+
211
+
212
+
213
+ override func viewWillAppear(_ animated: Bool) {
214
+
215
+ super.viewDidAppear(animated)
216
+
217
+
218
+
219
+ tableView.reloadData()
220
+
221
+ }
222
+
223
+
224
+
225
+
226
+
227
+ func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
228
+
229
+
230
+
231
+ return resultArray2.count
232
+
233
+
234
+
235
+ }
236
+
237
+
238
+
239
+ func numberOfSections(in tableView: UITableView) -> Int {
240
+
241
+ return 1
242
+
243
+ }
244
+
245
+
246
+
247
+ func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
248
+
249
+ let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
250
+
251
+
252
+
253
+
254
+
255
+ print("Array2:at cellForRowAt", Array2.description)
256
+
257
+ print(Array2.count)
258
+
259
+ print(resultArray2.description)
260
+
261
+ print(dateArray2.description)
262
+
263
+
264
+
265
+ cell.textLabel!.text = resultArray2[indexPath.row]
266
+
267
+ cell.detailTextLabel!.text = dateArray2[indexPath.row]
268
+
269
+
270
+
271
+ return cell
272
+
273
+ }
274
+
275
+
276
+
277
+ func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
278
+
279
+ return 40
280
+
281
+ }
282
+
283
+
284
+
285
+ func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCell.EditingStyle, forRowAt indexPath: IndexPath) {
286
+
287
+
288
+
289
+ if editingStyle == .delete {
290
+
291
+ Array2.remove(at: indexPath.row)
292
+
293
+
294
+
295
+ UserDefaults.standard.set(Array2, forKey: "save")
296
+
297
+
298
+
299
+ tableView.reloadData()
300
+
301
+ }
302
+
303
+ }
304
+
305
+
306
+
307
+ ```