This is for a blog-type app, in which the blog post is shown and below you can read the several comments to that post.
| Post Title Here
|
| Post text here lorem ipsum
| dolor bla bla bla
|
| ---------------------------------------------
| Comment 1
| ---------------------------------------------
| Comment 2
| ---------------------------------------------
| Comment 3
| ---------------------------------------------
| etc
My JSON feed looks like this:
...
{
"post_id": "1463",
"post_title": null,
"post_text": "dffsdjdflkjklk dlfkjsdlfkj",
"comment": [
{
"comment_id": "2162",
"comment_text": "yuiyuiiopiop",
},
{
"comment_id": "2163",
"comment_text": "tyutyutyutyuu",
},
{
"comment_id": "2164",
"comment_text": "sdfsertertr",
},
]
},
...
And this is how I read it
NSDictionary *post = self.detailItem;
NSArray *commentThread = [post objectForKey:@"comment"];
NSUInteger commentCount = [commentThread count];
for (int i = 0; i < commentCount; i++) {
NSDictionary *comment = [commentThread objectAtIndex:i];
NSString *commentText = [comment objectForKey:@"comment_text"];
commentTextLabel.text = commentText;
}
In my storyboard I have one UILabel that is wired to commentTextLabel
.
With the above approach only the last comment shows in my view. I expected the UILabel to be generated i
times but that does not seem to be the case.
How should I do to get multiple UILabels created, one for each comment, so they end up stacked as I show in the top of this post?
Any kind of help, pointers or advice is greatly appreciated.