valueForKeyPath の使用に問題があります。ここでは、dataVersion 値を取得する方法で、完全に機能します。
Alamofire.request(.GET, "https://www.amazon.fr/s", parameters:parameters)
.responseJSON { (_, _, JSON, _) -> Void in
let priceResult: String? = JSON?.valueForKeyPath("reponseMetadata.dataVersion") as String?
println(priceResult)
}
しかし、このように url 値にアクセスしようとすると、失敗します
Alamofire.request(.GET, "https://www.amazon.fr/s", parameters:parameters)
.responseJSON { (_, _, JSON, _) -> Void in
let priceResult: String? = JSON?.valueForKeyPath("preloadImages.images.url") as String?
println(priceResult)
}
ここで私の Json :
{
responseMetadata: {
dataVersion: "v0.1"
},
preloadImages: {
images: [
{
url: "http://ecx.images-amazon.com/images/I/51K4P7REBKL._SL500_AC_.jpg"
}
]
}
}
私はIOが初めてなので、どんな助けも大歓迎です!