質問編集履歴

2

コードの追記

2018/05/16 10:15

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -20,12 +20,10 @@
20
20
 
21
21
  var products: [[Cell]] = [[]]
22
22
 
23
-
24
-
25
-
26
-
27
23
  var cnt = 0
28
24
 
25
+ //以下の2つの変数は削除予定
26
+
29
27
  var item: [String] = []
30
28
 
31
29
  var itemTotal: [[String]] = [[]]

1

現在のコードの更新、困っているの事についての具体的な説明

2018/05/16 10:15

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -18,10 +18,16 @@
18
18
 
19
19
  let initialItems: [String] = []
20
20
 
21
- var products: [Cell] = []
21
+ var products: [[Cell]] = [[]]
22
+
23
+
24
+
25
+
22
26
 
23
27
  var cnt = 0
24
28
 
29
+ var item: [String] = []
30
+
25
31
  var itemTotal: [[String]] = [[]]
26
32
 
27
33
 
@@ -30,7 +36,7 @@
30
36
 
31
37
  if (products.count == 0
32
38
 
33
- || products.count > 0 && itemTotal[0].count == 0) {
39
+ || products.count > 0 && products[0].count == 0) {
34
40
 
35
41
  return 0
36
42
 
@@ -50,19 +56,19 @@
50
56
 
51
57
 
52
58
 
53
- let item1 = products[indexPath.row]
59
+ //let item1 = products[indexPath.row]
54
-
60
+
55
- cell.textLabel?.text = item1.title
61
+ //cell.textLabel?.text = item1.title
56
62
 
57
63
 
58
64
 
59
65
  let index = products.count - 1 - indexPath.row
60
66
 
61
- let item = itemTotal[index]
67
+ let item = products[index]//itemTotal[index]
62
-
63
-
64
-
68
+
69
+
70
+
65
- guard products.count > 0 else {
71
+ guard item.count > 0 else {
66
72
 
67
73
  return cell
68
74
 
@@ -82,7 +88,7 @@
82
88
 
83
89
  label.backgroundColor = UIColor.darkGray
84
90
 
85
- label.text = i
91
+ label.text = i //string型じゃないとダメらしい 52行目 Cannot assign value of type 'Cell' to type 'String?'
86
92
 
87
93
 
88
94
 
@@ -184,7 +190,7 @@
184
190
 
185
191
  let name = textField.text!
186
192
 
187
- self.products.insert(Cell(title: name, detail: name, cellcolor: false), at: 0)
193
+ self.products.insert([Cell(title: name, detail: name, cellcolor: false)], at: 0)
188
194
 
189
195
  print(textField.text!)
190
196
 
@@ -266,19 +272,19 @@
266
272
 
267
273
  let name = textField.text!
268
274
 
269
- self.products.append(Cell(detail: name, cellcolor: false ))
275
+ self.products.append([Cell(detail: name, cellcolor: false )])
270
-
276
+
271
- /*self.item.insert(textField.text!, at: 0)
277
+ self.item.insert(textField.text!, at: 0)
272
-
278
+
273
- self.itemTotal[self.cnt] = self.item
279
+ self.products[self.cnt] = self.item //146行目 Cannot assign value of type '[String]' to type '[Cell]'
274
280
 
275
281
 
276
282
 
277
- if self.item.count % 5 == 0, self.itemTotal[0].count > 1 {
283
+ if self.item.count % 5 == 0, self.products[0].count > 1 {
278
284
 
279
285
  self.cnt += 1
280
286
 
281
- self.itemTotal.append([])
287
+ self.products.append([])
282
288
 
283
289
  self.item = []
284
290
 
@@ -286,13 +292,13 @@
286
292
 
287
293
  //self.Gesture()
288
294
 
289
- //self.doubleclic()*/
295
+ //self.doubleclic()
290
296
 
291
297
  }
292
298
 
293
299
  self.mytableView.reloadData()
294
300
 
295
- //}
301
+ }
296
302
 
297
303
  }
298
304
 
@@ -406,9 +412,9 @@
406
412
 
407
413
 
408
414
 
409
- for detail in initialItems {
415
+ for detail in item {
410
-
416
+
411
- products.append(Cell(detail: detail, cellcolor: false))
417
+ products.append([Cell(detail: detail, cellcolor: false)])
412
418
 
413
419
  }
414
420
 
@@ -436,6 +442,8 @@
436
442
 
437
443
  }
438
444
 
445
+
446
+
439
447
  ```
440
448
 
441
449
 
@@ -501,3 +509,7 @@
501
509
  アラートはちゃんと呼び出せて入力したものがコンソールエリアに表示にされているのでアラートの処理の問題ではないと思われる。その為、cellForRowAt内に問題がると思われるが何が問題なのかが分からない。
502
510
 
503
511
  題名となるセルはセクションでも良いではないかという指摘はあるかもしれないがスワイプ処理なども考え、今回はセル2行で出来るようにしたいと考えている。
512
+
513
+ 52行目、146行目での構造体配列による型のエラーで困っています。
514
+
515
+ 他には各箇所のitemをdetailにしたいが構造体の中にあるので書き換えれなく困っています。