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

  • Home
  • SEARCH
  • 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 9000217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:17:00+00:00 2026-06-16T00:17:00+00:00

I have an NSMutableArray that contains objects of type Person. The Person object contains

  • 0

I have an NSMutableArray that contains objects of type Person. The Person object contains parameters of NSString *name, NSString *dateStamp, and NSString *testScore. What I would like to do using fast enumeration, is display the parameters of each object as UILabels on a row in a view, with each object being displayed on each row.

The problem is that the NSMutableArray may hold any number of objects, and therefore there may be one or two rows of labels on the view, or several rows on the view. I want to create a for loop that will dynamically populate the view with each object on a line (and consistently spaced), as well as allow the user to scroll down to see any rows that are further down and cannot be seen initially on the screen.

My for loop looks like this:

for (Person *checkPerson in personList) {
    UILabel *label1 =  [[UILabel alloc] initWithFrame: CGRectMake(10, 10, 50, 20)];
    label1.text = Person.name;

    UILabel *label2 =  [[UILabel alloc] initWithFrame: CGRectMake(70, 10, 50, 20)];
    label2.text = Person.dateStamp;

    UILabel *label3 =  [[UILabel alloc] initWithFrame: CGRectMake(130, 10, 50, 20)];
    label3.text = Person.testScore;

    [self.view addSubView:label1];
    [self.view addSubView:label2]; 
    [self.view addSubView:label3];
 }

What I need to do is dynamically adjust the “y” value in the CGRectMake field such that each object is sequentially moved down on another line as the NSMutableArray is iterated, and such that the user is able to scroll down to further see additional rows if necessary. Is the scrolling feature added automatically?

  • 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-16T00:17:00+00:00Added an answer on June 16, 2026 at 12:17 am

    you should do block enumeration, as this gives you also an index, that you can use to calculate y

    [personList enumerateObjectsUsingBlock:^(Person *person, NSUInteger idx, BOOL *stop) {
        UILabel *label1 =  [[UILabel alloc] initWithFrame: CGRectMake(10, 10+20*idx , 50, 20)];
        label1.text = person.name;
        UILabel *label2 =  [[UILabel alloc] initWithFrame: CGRectMake(70, 10+20 *idx, 50, 20)];
        label2.text = person.dateStamp;
    
        UILabel *label3 =  [[UILabel alloc] initWithFrame: CGRectMake(130, 10+20*idx, 50, 20)];
        label3.text = person.testScore;
    
        [self.view addSubView:label1];
        [self.view addSubView:label2]; 
        [self.view addSubView:label3];
    }];
    

    You should place them on an UIScrollView, where you set the contentSize according to the number of elements in the array.

    scrollView.contentSize = CGSizeMake(<width>, [personList count] / 3 *30);
    

    You also should consider using an UITableView. It might be easier and cell re-use keeps the memory usage low.

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

Sidebar

Related Questions

I have an NSMutableArray that contains objects of type Person. The Person object contains
I have an NSMutableArray that contains a list of objects of type MyClass, with
I have a class (from NSObject ) that contains: NSString name int position float
I have a NSMutableArray which contains a few NSString objects. How can I test
I have a NSMutableArray with objects of type NSMutableDictionary , the NSMutableDictionary contains 2
My NSMutableArray instance contains instances of different types of objects that have common ancestor.
I have a NSDictionary that contains objects and keys. The Keys hold a Name
I have two NSArray objects that I would like to be sorted the same.
Good day. I have an NSMutableArray that contains references to objects. I need to
I have an NSMutableArray that contains 2 types of Objects. Both objects contain a

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.