In general, the problem is the following: I have an array in which the entry is, let's say:

"name" : "Key" "comments" : [], 

and in it an array of comments to the post, how can be displayed in the table (list):

record, and under it comments, I understand that my record is the section, and the comment is the lines in the section, but I cannot understand how to implement it, I will be very grateful for the help!

  • Is nobody aware? ( - Zarochintsev

1 answer 1

if a post is a section, and comments are strings, then something like:

 - (NSInteger)numberOfSectionInTableView:(UITableView *)tableView { return self.items.count; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.items[section][@"comments"] count]; } - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return [MySectionHeader headerWithText:self.items[section][@"name"]]; } - (UITableViewCell *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MyCommentCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier]; MyComment *object = self.items[indexPath.section][@"comments"][indexPath.row]; /*configure cell here */ return cell; }