func makeGetRequest(){
var url : String = "http://apiairline.sunkhoai.com/api-v2/get-airinfo?ver=2?iata=ALL&direction=ALL"
var request : NSMutableURLRequest = NSMutableURLRequest ()
request.URL = NSURL(string: url)
request.HTTPMethod = "GET"
NSURLConnection.sendAsynchronousRequest(request, queue: NSOperationQueue(), completionHandler:{ (response:NSURLResponse!, data: NSData!, error: NSError!) -> Void in
var error: AutoreleasingUnsafeMutablePointer<NSError?> = nil
let jsonResult: NSDictionary! = NSJSONSerialization.JSONObjectWithData(data, options:NSJSONReadingOptions.MutableContainers, error: error) as? NSDictionary
var _names: NSMutableArray = NSMutableArray()
if (jsonResult != nil) {
// Success
// println(jsonResult)
let dataArray = jsonResult["airinfo_list"] as NSArray;
var _names: NSMutableArray = NSMutableArray()
for item :AnyObject in dataArray{
let obj = item as NSDictionary
_names.addObject(item)
self.TableData = _names
dispatch_async(dispatch_get_main_queue()) {
self.tableView.reloadData()
}
}
} else {
// Failed
println("Failed")
}
})
}
how do I display all the information of an object
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
how do I display all the information of an object
if let airinfo_list = TableData[indexPath.row] as? NSDictionary{
var ten = airinfo_list.valueForKey("AirNumberEx") as NSString
cell.textLabel?.text = ten
}
return cell