0
我很難從2維JSON結構獲取值並將其放入TableView中。 我用AFNetworking來獲取JSON數據。此代碼建立在Xcode 6測試7:如何從JSON 2維結構(嵌套字典)獲取值?
func apiConnetion() {
var result: NSArray = []
manager.GET("https://example.com/",
parameters: nil,
success: { (operation: AFHTTPRequestOperation!,responseObject: AnyObject!) in
result = responseObject as NSArray
println(result)
dispatch_async(dispatch_get_main_queue(), {
self.commentData = result
self.commentTableView!.reloadData()
})
},
failure: { (operation: AFHTTPRequestOperation!,error: NSError!) in
println("error")
println(" \(error.localizedDescription) ")
})
}
println(result)
打印的結構是這樣的:
{
"id" = 1;
"name" = "Test1";
"category" =
"id" = 1;
"name" = "justtest";
}
{
"id" = 2;
"name" = "Test2";
"category" =
"id" = 2;
"name" = "justtest1";
}
如何獲得類別名稱?
謝謝。有用 – 2014-09-05 02:24:07