首页 > 代码库 > Objective-C 字符串与数值互相转换

Objective-C 字符串与数值互相转换

Convert NSString to int

 

NSString *aNumberString = @"123";int i = [aNumberString intValue];

 

 Convert int to NSString

int aNumber = 123;NSString *aString = [NSString stringWithFormat:@"%d", aNumber];