Skip to content

FUIIndexTableViewDataSource giving unexpected results #244

@codemodouk

Description

@codemodouk

Step 2: Describe your environment

  • Objective C or Swift: Swift
  • iOS version: 9.3
  • Firebase SDK version: 3.6
  • FirebaseUI version: 2.0.2
  • CocoaPods Version: 1.1

Step 3: Describe the problem:

The snapshots returned from a FUIIndexTableViewDataSource object are in an unexpected format.

I have a 'user-listings' index ref with data structured as follows:

"user-listings" : {
  "K4jtmetqwFP30VCprAby2JQxm9k1" : {
    "-Kafe2ooXzkQtUcNeHgl" : -1.484643648826172E12,
    "-KblExHpQ7MbbfOvd7K8" : -1.48581120946895E12,
    "-KblGjxD-UUMJxA8-DZj" : -1485811679118
  }
}

I have a 'listings' data ref with data structured as follows

"listings" : {
 "-Kafe2ooXzkQtUcNeHgl" : {
   "make" : "VAUXHALL",
   "model" : "Vectra",
   "numberOfDoors" : 5,
   "odometer" : 100618,
   "yearOfManufacture" : 2001
  }
}

When I print to the console the snapshots returned from using the tableView.bind(toIndexedQuery: dataRef) method I see the following:

Snap (make) VAUXHALL
Snap (model) Vectra
Snap (numberOfDoors) 5
Snap (odometer) 100618
Snap (-Kafe2ooXzkQtUcNeHgl) {
    make = VAUXHALL;
    model = Vectra;
    numberOfDoors = 5;
    odometer = 100618;
}

It appears that I get a snapshot for each child of the data corresponding to the index I've queried followed by a snapshot of the data I was expecting.

Relevant Code:

class MasterTableViewController: UITableViewController {

var dataSource: FUIIndexTableViewDataSource!

override func viewDidLoad() {
    super.viewDidLoad()


    let indexQuery = FIRDatabase.database().reference()
        .child("user-listings")
        .child(AppState.shared.uid)

    let dataRef = FIRDatabase.database().reference()
        .child("listings")

    dataSource = tableView.bind(toIndexedQuery: indexQuery, data: dataRef, delegate: self, populateCell: { (tableView, indexPath, snapshot) -> UITableViewCell in
        let cell = tableView.dequeueReusableCell(withIdentifier: "reuseIdentifier", for: indexPath)

        if let snapshot = snapshot {
            print(snapshot)
        }
        return cell
    })
    tableView.dataSource = dataSource
}
}

I had posted the same issue to stackoverflow to see if this was an error in the way I was using the methods, but, I haven't had any responses to the issue. I would really appreciate some pointers if anyone has any.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions