Convert NSNumber to NSInteger

 

Example code how to convert NSNumber to NSInteger and NSInteger to NSNumber. 
Using:
Xcode 4.2.1
Mac OS X 10.7.2
Cocoa
 
From NSNumber to NSInteger
A simple function that returns an NSInteger from a NSNumber object.

 

 

- (NSInteger)NSnumberToNSinteger:(NSNumber *)NSnumber

{

    NSInteger returnInteger = [NSnumber integerValue];

    return returnInteger;

}

 

 

From NSInteger to NSNumber

A simple function that returns an NSNumber from a NSInteger object.

 

 

- (NSNumber *)NSintegerToNSnumber:(NSInteger)NSinteger

{

    NSNumber *returnNumber = [NSNumber numberWithInteger:NSinteger];

    return returnNumber;

}