Question

if I`m getting a string from IBOutlet I use:

NSString *stringName = [[self IBOutletName] text];

but how can I get a value if it`s a number?

Was it helpful?

Solution

Here ya go:

NSString * someNumberString = [[self IBOutletName] text];
int someInt = [someNumberString intValue];

Note, I'm sure there are more, but just asa starter, you can also use:

float someFloat = [someFloatString floatValue]; // for floats
double someDouble = [someDoubleString doubleValue]; // for doubles

If you want the string value from an NSNumber just do:

NSString * stringValue = [someNSNumber stringValue];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top