尝试在填充了JSON的变量上使用dump方法。但它不起作用,我不明白为什么
import UIKit
class ViewController: UIViewController {
var hoge: JSON?
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "https://api.whitehouse.gov/v1/petitions.json")
var request = NSURLRequest(URL: url!)
var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: nil, error: nil)
if data != nil {
hoge = JSON(data: data!)
let count = hoge!["results"][0]["body"].stringValue
println(count)
}
}
func res() {
dump(self.hoge)
}
}
你能帮我看看我做错了吗?