initWith
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