标签:
1.NSNumber是用来封装基本类型的对象,任何数据封装成NSNumber的时候都可以进行相互比较,或者逻辑运算
2.NSNumber的声明
NSNumber * intNumber = [[[NSNumber alloc] initWithInt:9] autorelease]; NSNumber * floatNumber = [[[NSNumber alloc] initWithFloat:9.0f] autorelease]; NSNumber * doubleNumber = [[[NSNumber alloc] initWithDouble:10] autorelease]; NSLog(@"%@,%@,%@",intNumber,floatNumber,doubleNumber); NSLog(@"%d",[intNumber isEqualTo:floatNumber]);
3.将NSNumber转换成基本类型
NSLog(@"%d",[intNumber intValue]); NSLog(@"%f",[floatNumber floatValue]); NSLog(@"%f",[doubleNumber doubleValue]);
标签:
原文地址:http://www.cnblogs.com/zwhFighting/p/4553288.html