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