سؤال

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?

هل كانت مفيدة؟

المحلول

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];
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top