문제

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