こんな感じのJSONを読みます
{{"midashi":
[{"hoge":"1", "imageurl":"htt://www.hoge.com/uri01.png"},
{"hoge":"2", "imageurl":"htt://www.hoge.com/uri02.png"},
{"hoge":"3", "imageurl":"htt://www.hoge.com/uri03.png"}]
}
// NSUrlSessionの取得ハンドラ
func onFinishGetUri(data: NSData?, res: NSURLResponse?, error: NSError?){
var dict:NSDictionary
do{
dict = try NSJSONSerialization.JSONObjectWithData(data, options: NSJSONReadingOptions.MutableContainers) as! NSDictionary
let imageList = dict["midashi"] as! NSArray
for image in imageList{
let url = image["imageurl"] as! String
print(url)
getList.append(url) // 詰め直してみる
}
// index0のurlを取得
print(getList[0])
} catch {
print("error")
return
}
}
0 件のコメント:
コメントを投稿