Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8674415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:42:19+00:00 2026-06-12T19:42:19+00:00

This is for a blog-type app, in which the blog post is shown and

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:42:20+00:00Added an answer on June 12, 2026 at 7:42 pm

    Since you have one UILabel hooked up in your storyboard, you are overwriting it’s content in every iteration.

    What you want to do is to create a new UILabel for each comment, set it’s frame and add it as a subview to it’s parent view and iterate to the next.

    For example:

    for (int i = 0; i < commentCount; i++) {
        NSDictionary *comment      = [commentThread objectAtIndex:i];
        NSString     *commentText  = [comment objectForKey:@"comment_text"];
        UILabel      *newLabel     = [UILabel alloc] init];
    
        newLabel.text = commentText;
        newLabel.frame = CGRectMake(origin.x, origin.y, width, height);
        [self.view addSubview:newLabel];
    }
    

    origin.x, origin.y would have to be calculated each time to fit your needs, you could insert a variable to hold the last origin.y and add it’s height and a margin each time to make it look like a list.

    On the other hand, the most efficient way to do this would be to use a UITableView. Your JSON could be parsed into an array and each entry would be a cell. This way you take advantage of reusing cells. If you do not reuse cells and keep going with your current setup, your app’s performance could be affected if you have too many comments.

    Also take into consideration that presenting labels in a TableView or ScrollView isn’t very effective framerate-wise. The alpha-blending will cut into your performance. I suggest you also google about tweetie’s fast performing tableviews or check this post
    atebits Twitter fast scrolling

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following the instructions on using xsi:type from this oft-cited blog post: http://blog.bdoughan.com/2010/11/jaxb-and-inheritance-using-xsitype.html Basically
This blog post of December 2008 says that rubygems is broken on Debian-based systems.
On this blog post , it's said that the minimum memory usage of a
Just finished reading this blog post: http://www.skorks.com/2010/03/an-interview-question-that-prints-out-its-own-source-code-in-ruby/ In it, the author argues the case
In a Rails 3 blog type of app, I have a polymorphic comments model,
In this blog, http://www.bswebdev.com/2008/12/javascript-change-input-box-type-to-password/ I have found the following snippets for fixing change input
I've recently found this blog entry on a tool that writes XSS attacks directly
In a mini blog app, I want to create a delete function, so that
I'm building an app that notifies user when new ThreadedComments appear. For this I'm
I've created an app that has several models (say A, B) that are polymorphically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.