回答編集履歴

2

更新をfor分の下に移動してその上で確認して0件になってますか?

2019/08/03 12:12

投稿

TakuyaAso
TakuyaAso

スコア1361

test CHANGED
@@ -21,3 +21,59 @@
21
21
  配列の要素数が一致していない可能性があります。
22
22
 
23
23
  ブレークポイントなどを上記のコード部分に設置し各配列の要素数を確認してください!
24
+
25
+
26
+
27
+ ```swift
28
+
29
+ //非同期通信
30
+
31
+ Alamofire.request(request).validate().responseJSON { response in
32
+
33
+ switch response.result {
34
+
35
+ case .success(let value):
36
+
37
+ let json = JSON(value)
38
+
39
+ print(json)
40
+
41
+ for i in 0 ..< json.count{
42
+
43
+ self.title_box.append(json[i]["articleTitle"].string!)
44
+
45
+ self.publisher_box.append(json[i]["siteTitle"].string!)
46
+
47
+ self.articleURL_box.append(json[i]["articleURL"].string!)
48
+
49
+ self.imageURL_box.append(json[i]["imageURL"].string!)
50
+
51
+ }
52
+
53
+ print(String(self.title_box.count))
54
+
55
+ print(String(self.publisher_box.count))
56
+
57
+ print(String(self.articleURL_box.count))
58
+
59
+ print(String(self.imageURL_box.count))
60
+
61
+ DispatchQueue.main.async {
62
+
63
+ self.collectionView.reloadData()
64
+
65
+ }
66
+
67
+ }
68
+
69
+
70
+
71
+ case .failure(let error):
72
+
73
+ print(error)
74
+
75
+ }
76
+
77
+ }
78
+
79
+ ```

1

調査依頼

2019/08/03 12:12

投稿

TakuyaAso
TakuyaAso

スコア1361

test CHANGED
@@ -13,3 +13,11 @@
13
13
  }
14
14
 
15
15
  ```
16
+
17
+
18
+
19
+ 問題ないということなので
20
+
21
+ 配列の要素数が一致していない可能性があります。
22
+
23
+ ブレークポイントなどを上記のコード部分に設置し各配列の要素数を確認してください!