====== initWith ======
- (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);
===== ObjC Sourcecode Example =====
//** Sample Datatypes **
int myInt = 30;
double myDouble = 3.14;
BOOL myBool = NO;
float myFloat = 1.123456f;
//******************** Initializing NSNumber Objects *************************
//** NSNumbers need to be released, if you`re not working with ARC! **
NSNumber *myBoolNumber = [[NSNumber alloc]initWithBool:myBool];
NSNumber *myIntNumber = [[NSNumber alloc]initWithInt:myInt];
NSNumber *myDoubleNumber = [[NSNumber alloc]initWithDouble:myDouble];
NSNumber *myFloatNumber = [[NSNumber alloc]initWithFloat:myFloat];
NSLog(@"myBoolNumber: %@", myBoolNumber);
NSLog(@"myIntNumber: %@", myIntNumber);
NSLog(@"myDoubleNumber: %@", myDoubleNumber);
NSLog(@"myFloatNumber:%@", myFloatNumber);
==== Output for this example code ====
2012-05-20 19:26:47.796 NSNumberSample[818:f803] myBoolNumber: 0
2012-05-20 19:26:47.830 NSNumberSample[818:f803] myIntNumber: 30
2012-05-20 19:26:47.831 NSNumberSample[818:f803] myDoubleNumber: 3.14
2012-05-20 19:26:47.832 NSNumberSample[818:f803] myFloatNumber:1.123456