私はAlamofireを使用してTableViewを生成します。 これは私のコードの抜粋です:Alamofire JSON応答の間違った順序
var arrRes = [[String:AnyObject]]()
Alamofire.request(api_url5).responseJSON { (responseData) -> Void in
if((responseData.result.value) != nil) {
let swiftyJsonVar = JSON(responseData.result.value!)
if let resData = swiftyJsonVar["data"].arrayObject {
self.arrRes = resData as! [[String:AnyObject]]
print (api_url5)
print (self.arrRes)
}
if self.arrRes.count > 0 {
self.tblDetail.reloadData()
}
}
}
要求がポストマンに正しい順序を出力し、「並べ替え」のパラメータを持っています。しかし、テーブル内のアイテムの順序が間違っていて、出力がprint (self.arrRes)
でも届いています。
私はAPIからどのように注文するのですか?ポストマンで
受注:コンソールで
{
"data": [
{
"we": "text",
"de": "text",
"se": "text",
"ve": "text",
"qe": "text",
"ne": "text"
},
{
"we": "wer",
"de": "wer",
"se": "wer",
"ve": "wer",
"qe": "wer",
"ne": "wer"
}
]
}
注文:
{
"data": [
{
"we": "wer",
"de": "wer",
"se": "wer",
"ve": "wer",
"qe": "wer",
"ne": "wer"
},
{
"we": "text",
"de": "text",
"se": "text",
"ve": "text",
"qe": "text",
"ne": "text"
}
]
}
@Francis彼らは逆転している可能性があります、それを2つ以上のアイテムを返すようにしようとすることはできますか? – TNguyen
@ TPN1994 2つ以上の商品を返品しても、注文が間違っています。しかし、パターンがなければ、ちょうど混ざりました... – Francis
SwiftyJSONの代わりに 'responseData.result.value'に' JSONSerialization'を使用できますか?ちょうどそれがリクエストかSwiftyJSONかどうかをチェックすることです。また 'swiftyJsonVar'も印刷できますか?おそらく '' swiftyJsonVar ["data"] 'は確かでしょうか? – Larme