0
votes

I am using includeKey to load multiple values from an array column in my PFObject. When I navigate to the tableView, however, the tableView only loads a single row

This is because the Parse cellForRowAtIndexPath method is only called once (when it should be called for the amount of values in the "following" array)

Here's my implementation

override func queryForTable() -> PFQuery {
    let query = PFQuery(className: "Followers")
    query.whereKey("username", equalTo: username)
    query.includeKey("following")

    return query
}

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath, object: PFObject?) -> PFTableViewCell? {
    let cell = tableView.dequeueReusableCellWithIdentifier(identifier) as! AccountQueryCell
    let followerObject = object as! PFFollowers

    cell.usernameLabel.text = followerObject.getFollowing()[indexPath.row]
    cell.profileImage.username = followerObject.getFollowing()[indexPath.row]

    return cell
}

As you can see, I return a query that includes the "following" array.

My Parse "Followers" class contains the following custom columns: "following" (Array) and "username" (String)

Could someone explain to me why my query isn't calling cellForRowAtIndexPath for every value in the following array?

1

1 Answers

1
votes

I think the issue is that you are querying for all Followers objects which match a single username. Based on the description of your data model, this will result with only one object being found.

PFQueryTableViewController automatically sets the table view's data source according to the results of your query. In other words, the table view is being set to only create one cell to correspond to the one result from the query.