所以我试图获取JSON文件,当我将它打印到控制台时,它似乎都能正常工作。
var dta:JSON = nil
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://www.vikinglogue.com/api/get_posts/")
var request = NSURLRequest(URL: url!)
var data = NSURLConnection.sendSynchronousRequest(request, returningResponse: nil, error: nil)
if data != nil {
dta = JSON(data: data!)
println(dta)
}
self.tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "cell")
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
cell.textLabel?.text = self.dta["count"].stringValue
println(self.dta["count"].stringValue)
return cell
}
虽然," println(self.dta [" count"]。stringValue)"什么时候打印出来的东西不打印出12。 我做错了什么?