そのため、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 を出力する必要があるときに何も出力しません。何が間違っていますか?