Sam Jarman
Sam Jarman

Reputation: 7377

Weird behavior with UILabel and Text propert

Im trying to do something that I think is super simple.

i have 3 integers - prevgues1 , 2 and 3

and i have 3 UILabels prevguess1, 2 and 3

the ints have 1 less s.

When I set the text of the label so

prevguess1.text = [NSString stringWithFormat:@"%d", prevguess1]
prevguess2.text = [NSString stringWithFormat:@"%d", prevguess2];
prevguess3.text = [NSString stringWithFormat:@"%d", prevguess3];

the label just set to a number like 89324 or something like that.

I just don't know what my problem is.

Any ideas would be helpful

Cheers

Sam

Note:

I have tried setting the text simply to a string - and have had luck. but when i set it to a integer, which start as 0 value, (in viewdidload) the weirdness happens

Upvotes: 0

Views: 75

Answers (1)

Vladimir
Vladimir

Reputation: 170849

prevguess1.text = [NSString stringWithFormat:@"%d", prevguess1];

Here you treat prevguess1 as a label and as an integer - probably there's a typo somewhere?

Even if it's not a matter of your problems I think you should consider changing the way you name your variables a bit to avoid possible confusion.

Upvotes: 1

Related Questions