Is a little problem 开发者_运维技巧with save int variable to label.
int i = idpole;
[lid2 setText:@"%i", i];
Thats bad, but i tried more thing... i cant set this "settext:i", because this doesnt work. I try found something on google, but without sense.
use
int i = idpole;
[lid2 setText:[NSString stringWithFormat:@"%i", i]];
The text
property of label is a NSString
, so you can not set an integer directly. You need to convert that int to a string. You can use any of the followings:
lid2.text = [NSString stringWithFormat:@"%i", idpole]; // no need of temporary i
// or
[lid2 setText:[NSString stringWithFormat:@"%i", idpole]];
int i = idpole;
[lid2 setText:[NSString stringWithFormat:@"%d",i]];
精彩评论