All health. Not so long ago, I began to learn programming under iOS, and very quickly the question arose as follows:

For UIlabel and UItextField there is a text attribute that refuses to work with int and others like it. I can not find others, even on the Apple site. In the end, I can only write something like this:

-(IBAction)btn:(id)sender { textField.text = @"Hey"; textLabel.text = textField.text; } 

A search on the Internet gave information about some kind of NSString conversion to NSInteger, but I do not understand it.

My goals:

There is a button, label and textfield. Suppose I enter some value from the keyboard into the textField, let it be 33000, I press a button, and some other number is put on the label, say, 10,000. Simply put, the converter is something.

    1 answer 1

     - (IBAction) btn:(id)sender { int myInteger = [self.textField.text intValue]; int result = myInteger * 2; self.label.text = [NSString stringWithFormat:@"%d", result]; }