質問編集履歴
1
項目の整理 文言追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,36 +1,30 @@
|
|
1
|
-
現在APIを叩いて返ってきた値を使ってUITableViewで表示するアプリを書いています。
|
1
|
+
現在APIを叩いて返ってきた値を使ってUITableViewで表示するアプリを書いています。Alamofireのresponse.result.valueで取得できる値は以下のようになっています。
|
2
2
|
|
3
3
|
```json
|
4
|
-
[{
|
5
|
-
"
|
4
|
+
[{"created_at" : "aaa"
|
6
|
-
"
|
5
|
+
"author" : "bbb"
|
7
|
-
"
|
6
|
+
"score" : "ccc"
|
8
7
|
|
9
8
|
},{
|
10
|
-
"
|
9
|
+
"created_at" : "aaa"
|
11
|
-
"
|
10
|
+
"author" : "bbb"
|
12
|
-
"
|
11
|
+
"score" : "ccc"
|
13
12
|
}]
|
14
13
|
```
|
15
14
|
|
16
15
|
DataModelを作成して代入するところが以下のようになっています。
|
17
16
|
```swift
|
18
|
-
|
17
|
+
func getCellData(json:JSON){
|
19
18
|
if let postedDateUnixTime = json[0]["created_at"].string {
|
20
|
-
postedDataModel.postedDate = postedDateUnixTime
|
21
19
|
postedDataModel.postedBy = json[0]["author"].stringValue
|
22
20
|
postedDataModel.scoreNumber = json[0]["score"].stringValue
|
23
|
-
postedDataModel.sourceNumber = json[0]["source"].stringValue
|
24
|
-
postedDataModel.tags = json[0]["tags"].stringValue
|
25
|
-
postedDataModel.rate = json[0]["rating"].stringValue
|
26
|
-
postedDataModel.rateIconName = postedDataModel.updateRateIcon(rate: postedDataModel.rate)
|
27
21
|
print(postedDataModel.postedBy)
|
28
|
-
|
22
|
+
}
|
29
23
|
else{
|
30
24
|
print("API unavailable")
|
31
25
|
}
|
32
|
-
}
|
26
|
+
}
|
33
|
-
|
27
|
+
|
34
28
|
```
|
35
29
|
|
36
30
|
---
|