user773461
user773461

Reputation: 1

Take string from UITextField and use it as a double

I'm trying to make a unit converter as my first app. I've been having trouble getting the numeric value from the textfield, so I can multiply it by whatever constant to convert the units. Also, how can I add a decimal place to a numeric key pad?

Upvotes: 0

Views: 1292

Answers (2)

brandontreb
brandontreb

Reputation: 397

float value = [self.myTextField.text floatValue];

Upvotes: 2

csano
csano

Reputation: 13686

Use the NSString doubleValue property to convert the string value from the UITextBox into a double.

double d = [str doubleValue];

Upvotes: 4

Related Questions