數字對象初始化code
int number = 10; NSNuber *intNum = [NSNumber numberWitherInt:number] BOOL isBool = YES; NSNumber *boolNum = [NSNumber numberWithBbool:isBool];
此方法須要對內存進行管理對象
float pi = 3.14; NSNumber *piNum = [[NSNumber alloc] initWithFloat:pi]; char character = 'a'; NSNumber *cNum = [[NSNumber alloc] initWithChar:cNum];
NSNumber轉基本數據類型內存
int num = [intNum intValue]; BOOL isBool = [boolNumber boolValue];