I have a tableview that I fill with results from an http call. The data is passed on into the array called `tripTimes`. `triptimes` contains information about certain trips made during a given day. The starting time of every trip of that day is passed into `self.tableData` and is inserted into the tableView.

After this, I reload the table and... strange results. 

The array `tableData` gets filled properly, but after I call `self.tableView.reloadData()` almost all cells are properly filled. However, the first cell is left empty until I tap it or if I wait for about 5 seconds and the last cell is also empty, but it gets the same value as the first cell after the same time. 

I think it has to do something with the `dispatch_async` part, but I'm fairly new to swift and iOS, so I have no clue where to look. When I print the contents of `self.tableData` inside the `dispatch_async` function, the array contains the proper values.

Below is the code for my viewController

```
import UIKit
import Foundation
import SwiftHTTP
class TripSelect: UIViewController, UITableViewDataSource, UITableViewDelegate {

    @IBOutlet weak var dateTextField: UITextField!
    @IBOutlet weak var tableView: UITableView!

    @IBAction func showTrips(sender: AnyObject) {

        //if data is already present in tableData, empty it first
        if self.tripTimes.count != 0 && self.tableData.count != 0 {
            for var i=0; i<self.tripTimes.count; i++ {
                self.tableData.removeObjectAtIndex(0)
                let indexPathToRemove = NSIndexPath(forRow: 0, inSection: 0)
                self.tableView.deleteRowsAtIndexPaths([indexPathToRemove], withRowAnimation: .Automatic)
            }
            dispatch_async(dispatch_get_main_queue(), {
                self.tableView.reloadData()
            })
        }
        var request = HTTPTask()
        request.GET("<MY_URL>", parameters: ["date": dateTextField.text], success: {(response: HTTPResponse) in
            if let data = response.responseObject as? NSData {

                let str = NSString(data: data, encoding: NSUTF8StringEncoding) as String
                let str2 = "\"not enough data for this day\""

                if str != str2 {
                    let json:AnyObject = JSON.parse(str)

                    self.dayLatLongs = json["dayLatLongs"] as Array
                    self.tripTimes = json["tripTimes"] as Array

                    var tripLatLongs:[AnyObject] = self.dayLatLongs[0] as Array
                    var firstTrip:[AnyObject] = tripLatLongs[0] as Array
                    var tripStartTime:String = ""
                    for var i=0; i<self.tripTimes.count; i++ {
                        tripStartTime = self.tripTimes[i]["startTime"] as String
                        //println("\(tripStartTime)")
                        self.tableData.addObject(tripStartTime)
                        let indexPath = NSIndexPath(forRow: 0, inSection: 0)
                        self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic)
                    }
                    dispatch_async(dispatch_get_main_queue(), {
                        println(self.tableData)
                        self.tableView.reloadData()
                    })
                } else {println(str)}
            }
            },failure: {(error: NSError, response: HTTPResponse?) in
                println("error: \(error)")
        })
    }

    var dayLatLongs:[AnyObject] = []
    var tripTimes:[AnyObject] = []
    var tableData: NSMutableArray! = NSMutableArray()

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return self.tableData.count
    }
    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell: UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell
        cell.textLabel?.text = self.tableData.objectAtIndex(indexPath.row) as? String
        return cell
    }

    override func viewDidLoad() {
        super.viewDidLoad()
        var backgroundView = UIView(frame: CGRectZero)
        self.tableView.tableFooterView = backgroundView
        self.tableView.backgroundColor = UIColor.clearColor()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}

```

UPDATE:

```
var indexPaths:[NSIndexPath] = [NSIndexPath]()
for var i=0; i<self.tripTimes.count; i++ {
    tripStartTime = self.tripTimes[i]["startTime"] as String
    self.tableData.addObject(tripStartTime)
    indexPaths.append(NSIndexPath(forRow: i, inSection: 0))
}
self.tableView.insertRowsAtIndexPaths(indexPaths, withRowAnimation: .Automatic)

```

Now the results are shown properly, but only after I 'drag' the table a couple of times.