Can't display custom cell with PFQueryTableViewController (Swift2)

118 views Asked by At

Using parse.com v1.4 (installed with cocoa pods) with Swift 2 +

I've setup up my PFQueryTableViewController (ParseUI) with a custom cell. I believe everything is hooked up fine, however I can't get the cell to display the value from Parse.com even though I do receive it and can print it (I've debugged it).

I am dequeueing like this:

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell {

    let cellIdentifier = "Cell"

    let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! OrderTableViewCell

    // Extract values from the PFObject to display in the table cell
    if let pfObject = object {

        // prints expected value, e.g. 1, 2, 3
        print(pfObject["table"])

        // shows "Label" which is my label's default text on the SB!!
        let table = pfObject["table"] as? String
        cell.lblTable.text = table
    }
    return cell
}

The rest of my PFQueryTableViewController which seems to load data OK from Parse: enter image description here

My custom cell OrderTableViewCell (with some label IBActions): enter image description here

SB set-up:

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

And the result:

enter image description here

How can I get the label to display the actual text? What am I missing? I don't want to revert back to standard UITableView due to the additional features I get with Parse UI.

1

There are 1 answers

0
ppp On BEST ANSWER

turns out it was as simple as changing

let table = pfObject["table"] as? String

to

let table = String(pfObject["table"])