数值与NSNumber互转

@interface NSNumber : NSValue


- (char)charValue;

- (unsigned char)unsignedCharValue;

- (short)shortValue;

- (unsigned short)unsignedShortValue;

- (int)intValue;

- (unsigned int)unsignedIntValue;

- (long)longValue;

- (unsigned long)unsignedLongValue;

- (long long)longLongValue;

- (unsigned long long)unsignedLongLongValue;

- (float)floatValue;

- (double)doubleValue;

- (BOOL)boolValue;

- (NSInteger)integerValue NS_AVAILABLE(10_5, 2_0);

- (NSUInteger)unsignedIntegerValue NS_AVAILABLE(10_5, 2_0);


- (NSString *)stringValue;


- (NSComparisonResult)compare:(NSNumber *)otherNumber;


- (BOOL)isEqualToNumber:(NSNumber *)number;


- (NSString *)descriptionWithLocale:(id)locale;


@end


@interface NSNumber (NSNumberCreation)


- (id)initWithChar:(char)value;

- (id)initWithUnsignedChar:(unsigned char)value;

- (id)initWithShort:(short)value;

- (id)initWithUnsignedShort:(unsigned short)value;

- (id)initWithInt:(int)value;

- (id)initWithUnsignedInt:(unsigned int)value;

- (id)initWithLong:(long)value;

- (id)initWithUnsignedLong:(unsigned long)value;

- (id)initWithLongLong:(long long)value;

- (id)initWithUnsignedLongLong:(unsigned long long)value;

- (id)initWithFloat:(float)value;

- (id)initWithDouble:(double)value;

- (id)initWithBool:(BOOL)value;

- (id)initWithInteger:(NSInteger)value NS_AVAILABLE(10_5, 2_0);

- (id)initWithUnsignedInteger:(NSUInteger)value NS_AVAILABLE(10_5, 2_0);


+ (NSNumber *)numberWithChar:(char)value;

+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;

+ (NSNumber *)numberWithShort:(short)value;

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

+ (NSNumber *)numberWithInt:(int)value;

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

+ (NSNumber *)numberWithLong:(long)value;

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

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

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

+ (NSNumber *)numberWithFloat:(float)value;

+ (NSNumber *)numberWithDouble:(double)value;

+ (NSNumber *)numberWithBool:(BOOL)value;

+ (NSNumber *)numberWithInteger:(NSInteger)value NS_AVAILABLE(10_5, 2_0);

+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value NS_AVAILABLE(10_5, 2_0);

你可能感兴趣的:(Objective-C基础)