ios - Display int value as label -
Good evening, I'm new to iOS and I have a quick quick question.
I need help as well as how can I get the label of "label" to reflect the value of "number", which is a primitive difference that I set as 25 Have done The problem is that instead of showing 25, it shows 27896. I am sure that this is 25 in each other
I have to do this when the user will press the button with the "executed" ID, then
P>
here is my code Thanks!
#import "ViewController.h" @ Interface View Controller () @end @implementation ViewController int number = @ "25"; - (zero) viewDidoadload [[Super Viewedload]; // Setup an additional after loading the view, usually from a nib } - (zero) did risiv memorialisation [[super daviditamammy warning]; // Any resource settlement which can be reproduced. } - Execute (IBAction): (ID) sender {number = number * 2; [_Label setText: [NSString stringWithFormat: @ "% d", number]]; } @end
Thanks guys, your help will be extremely unfair.
#import "ViewController.h" @ interface view controller () @Ap @ Implementation View Controller Int number = 25; - (zero) viewDidoadload [[Super Viewedload]; // Setup an additional after loading the view, usually from a nib } - (zero) did risiv memorialisation [[super daviditamammy warning]; // Any resource settlement which can be reproduced. } - Execute (IBAction): (ID) sender {number = number * 2; [_Label setText: [NSString stringWithFormat: @ "% d", number]]; } @end
or
#import "ViewController.h" @ Interface View Controller () @end @implementation ViewController NSNumber number = @ 25; - (zero) viewDidoadload [[Super Viewedload]; // Setup an additional after loading the view, usually from a nib } - (zero) did risiv memorialisation [[super daviditamammy warning]; // Any resource settlement which can be reproduced. } - Execute (IBAction): (ID) sender {number = [NSNumber numberAttack: [number intValue] * 2]; // or number = @ ([number intValue] * 2); [_Label setText: [NSString stringWithFormat: @ "% @", number]]; } @end
What have you done, you have created a int
named number
(which is the number anyway) and assigned it to a continuous
NSString
object with value "25"
(in the form of string). Creates an NSNumber
object with the value of @ 25
25
.
Comments
Post a Comment