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?