首先说一下NSNumber的创建方式吧
NSNumber *charNum = [NSNumber numberWithChar:'123']; // C语言中中char【字符串】
NSNumber *shortNum = [NSNumber numberWithShort:123]; // 短整形
NSNumber *intNum = [NSNumber numberWithInt:123]; // 整形
NSNumber *longNum = [NSNumber numberWithLong:123]; // 长整型
NSNumber *floatNum = [NSNumber numberWithFloat:123.0]; // 单精度浮点数
NSNumber *doubleNum = [NSNumber numberWithDouble:123.00];// 双精度浮点数
NSNumber *boolNum = [NSNumber numberWithBool:YES]; // 布尔值
NSNumber *integerNum = [NSNumber numberWithInteger:123]; // 整形
1.NSNumber转化为NSString
NSNumber *intNum = [NSNumber numberWithInt:123]; // 整形
NSString * str = intNum.description;
2.NSString转化为NSNumber
NSString * str = @"123";
NSNumberFormatter *numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle:NSNumberFormatterDecimalStyle];
NSNumber *numTemp = [numberFormatter numberFromString:[NSString stringWithFormat:@"%@", str]];