0

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.

4

2 Answers 2

1
for (int i=0; i<[yourArr count]; i++) {
    yourLblObject.text=[NSString stringWithFormat:@"%@",[yourArr objectAtIndex:i]];
}
Sign up to request clarification or add additional context in comments.

2 Comments

when i am doing this way is giving object address like the -<pillbox: 0x5e1e090> .......but i want to show string in label...
Can you tell me what is in your array?
1

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;
}


 }

6 Comments

@virendra if You got the answer inform us if not then also so We can try to solve your problem.Thanks
ok......it is giving some waring Format not a string literal and no format arguments....
in this line -NSString *text = [NSString stringWithFormat:[arrStudents objectAtIndex:i]];
Which side you want your label y axis or x axis if you want on y then use y instant of x it will surely work for you because I am using same code for my apps.its work fine you try again and tell me exact error.I ll try to help you
do one this first create one mutable array add some object in that array and then pass that array in this text and above in for loop also call the same array.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.