iosDev
iosDev

Reputation: 604

how to fetch data from array?

I have created one NSarray, Now I want to display it's data in labels according to their index.

But not want to display them in table view cell.
I want to display them in simple labels.

Upvotes: 0

Views: 674

Answers (2)

vishiphone
vishiphone

Reputation: 750

use this code I think this will be helpful for you

 -(void)viewdidload
   {
 playerScores = [[NSArray arrayWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12",@"13",@"14",@"15",@"16",@"17",@"18",nil] retain];
 CGFloat y = 20;
for (int i = 0;i<[playerScores count];i++) {
    myLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, y, 60, 60)];
    myLabel.backgroundColor=[UIColor clearColor];

    [myLabel setFont:[UIFont fontWithName:@"Helvetica-Bold" size:35]];
    NSString *text = [NSString stringWithFormat:[playerScores objectAtIndex:i]];
    [myLabel setText:text];

    [yardsScrollView addSubview:myLabel];
    [myLabel release];
    y = y+125;
}


 }

Upvotes: 1

Kuldeep
Kuldeep

Reputation: 2589

for (int i=0; i<[yourArr count]; i++) {
    yourLblObject.text=[NSString stringWithFormat:@"%@",[yourArr objectAtIndex:i]];
}

Upvotes: 1

Related Questions