码迷,mamicode.com
首页 > 其他好文 > 详细

NSNumber简略了解

时间:2015-08-26 19:35:35      阅读:125      评论:0      收藏:0      [点我收藏+]

标签:

NSNumber简略了解

NSNumber是NSValue的子类,它提供C基本类型的值。char,short等等

1. 创建NSNumber对象的类方法(工厂方法)

+ (NSNumber *)numberWithBool:(BOOL)value
这个value的值时BOOL类型的

+ (NSNumber *)numberWithChar:(char)value
这个char是带符号的

+ (NSNumber *)numberWithDouble:(double)value

+ (NSNumber *)numberWithFloat:(float)value

+ (NSNumber *)numberWithInt:(int)value

+ (NSNumber *)numberWithInteger:(NSInteger)value

+ (NSNumber *)numberWithLong:(long)value

+ (NSNumber *)numberWithLongLong:(long long)value

+ (NSNumber *)numberWithShort:(short)value

+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value
这个char是不带符号的

+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value

+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value
注意,NSInteger和NSUInteger的区别,多了一个U,也就是unsigned的意思,一个带符号,一个不带符号

+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value

+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value

+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value

2. 初始化一个NSNumber对象

- (NSNumber *)initWithBool:(BOOL)value

- (NSNumber *)initWithChar:(char)value

- (NSNumber *)initWithDouble:(double)value

- (NSNumber *)initWithFloat:(float)value

- (NSNumber *)initWithInt:(int)value

- (NSNumber *)initWithInteger:(NSInteger)value

- (NSNumber *)initWithLong:(long)value

- (NSNumber *)initWithLongLong:(long long)value

- (NSNumber *)initWithShort:(short)value

- (NSNumber *)initWithUnsignedChar:(unsigned char)value

- (NSNumber *)initWithUnsignedInt:(unsigned int)value

- (NSNumber *)initWithUnsignedInteger:(NSUInteger)value

- (NSNumber *)initWithUnsignedLong:(unsigned long)value

- (NSNumber *)initWithUnsignedLongLong:(unsigned long long)value

- (NSNumber *)initWithUnsignedShort:(unsigned short)value

 

NSNumber简略了解

标签:

原文地址:http://www.cnblogs.com/zhangzjblog/p/4761218.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!