I'm currently developing my first App. The App is a Basic messenger App based on Parse.com.
I want to create a PFQueryTableViewController where it will show the recent chats with other users.
Photo of other user, Name of other user and timestamp (similar to Facebook messanger "recent" tab).
the chats data is saved in a Parse Class named Room with the following columns:
- objectid(string)
- roomname(string)
- User_1(pointer to _User)
- User_2(pointer to _User)...
I can fill the table view easily with the string values (e.g the roomname) but I would like to get the users @"full name" as the Label of each cell.
this is my code (I get an empty TableView):
- (PFQuery *)queryForTable {
PFQuery *query = [PFQuery queryWithClassName:@"Room"];
[query includeKey:@"User_2"];
if (self.objects.count == 0) {
query.cachePolicy = kPFCachePolicyCacheThenNetwork;
}
[query orderByDescending:@"createdAt"];
return query;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
object:(PFObject *)object
{
static NSString *cellIdentifier = @"Cell";
PFTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (!cell) {
cell = [[PFTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = object[@"fullname"];
return cell;
}