I try to populate my TableView with information that i get from a JSON But already on numberOfRowsInSection it does not work
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
let getVideoCount = Alamofire.request(.GET, APICall).responseJSON { (responseData) -> Void in
dispatch_async(dispatch_get_main_queue(), { () -> Void in
let swiftyJsonVar = JSON(responseData.result.value!)
if let resData = swiftyJsonVar["items"].arrayObject {
self.arrRes = resData as! [[String:AnyObject]]
}
print(self.arrRes.count) //runs after
})
}
getVideoCount.resume()
print(self.arrRes.count) //runs first
return arrRes.count
}
i try with the dispatch_async to run the JSON call before return the value, but still it print the //runs first before the //runs after