Converting int to NSInteger [duplicate] Converting int to NSInteger [duplicate] ios ios

Converting int to NSInteger [duplicate]


An improved answer

On 64-bit systems NSInteger is long. On 32-bit systems NSInteger is int.https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Cocoa64BitGuide/64BitChangesCocoa/64BitChangesCocoa.html

All you need just cast your int to NSInteger.

int i = 1;NSInteger nsi = (NSInteger) i;

You can also cast NSInteger to int (as in an original answer), but you must be careful on 64-bit system, because your NSInteger can exceed int limits.

An original answer

int i;NSInteger nsi = 1;i = nsi;

No big science. :)