Table of Contents

initWithInteger

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

ObjC Sourcecode Example

    NSInteger myInteger = 20;
 
    //******************** Initializing NSNumber Object *************************
 
    //** NSNumbers need to be released, if you`re not working with ARC! **
 
    NSNumber *myIntegerNumber = [[NSNumber alloc]initWithInteger:myInteger];
 
    NSLog(@"myIntegerNumber: %@", myIntegerNumber);
 

Output for this example code

2012-08-31 22:37:05.699 NSNumberSample[808:f803] myIntegerNumber: 20