RanchoSoftware RanchoSoftware - 4 years ago 166
iOS Question

iOS FirebaseUI with Custom UITableViewCell

I'm trying to populate a UITableView with custom UITableViewCells using FirebaseUI. Everything seems to work except that the TableViewCells delivered by the FirebaseTableViewDataSource.populateCell() method are not "wired" to the outlets in the view. Here's an example:

This is the custom UITableViewCell class. The UITableView in the storyboard for the view controller being loaded has this custom cell class.

class JobTableViewCell : UITableViewCell {
@IBOutlet weak var labelJobName: UILabel!

Here's the code in ViewDidLoad() of the view controller that is setting up the table:

dataSource = FirebaseTableViewDataSource(ref : ref, cellClass : JobTableViewCell.self, cellReuseIdentifier: "JobTableViewCell", view: self.tableView);

dataSource.populateCell{(cell : UITableViewCell, obj : NSObject) -> Void in
let snapshot = obj as! FIRDataSnapshot;
let job = Job(snapshot);
let jobCell = cell as! JobTableViewCell
// jobCell and its outlets are nil so this next statement
// causes exception.
jobCell.labelJobName.text = job.name;

self.tableView.dataSource = self.dataSource;

So the question is how to get FirebaseUI to deliver the custom cell with the outlets wired up? I can't figure out how to do it.

Answer Source

My solution was to stop using FirebaseUI for iOS .

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download