Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jeremy1026

macrumors 68020
Original poster
Nov 3, 2007
2,216
1,030
am trying to display a variable in a label. I don't know how to do it in the SDK though. I know that the normal way to display a variable (in command line Objective-C) is,

Code:
printf("%i",variable);

So I tried something like that with the SDK knowledge I have and came up with variations of,

Code:
(IBAction)action {
variable == 3;
[label setText:@"%i",variable];
}

But it comes back with an error of too many arguments for setText. How do I make it show that variable in the label?
I am able to get the button to display words using,

Code:
[label setText:@"Words"];

So I know know that my button works.
 
I got it :)

Code:
- (IBAction)toOnes {
	variable = 3;
	label.text = [[NSNumber numberWithInt:variable] stringValue];
}

Then in the .h you have to define the label

Code:
	IBOutlet UILabel *label;
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.