hi,
e.g. NSInteger called a
[a value] is a EXC_BAD_ACCESS
how to convert NSInteger to int ?
(only small numbers < 32 are used)
hi,
e.g. NSInteger called a
[a value] is a EXC_BAD_ACCESS
how to convert NSInteger to int ?
(only small numbers < 32 are used)
Ta da:
NSInteger myInteger = 42;
int myInt = myInteger;
NSInteger
is nothing more than a 32/64 bit int. (it will use the appropriate size based on what OS/platform you're running)
I'm not sure about the circumstances where you need to convert an NSInteger
to an int
.
NSInteger is just a typedef:
NSInteger Used to describe an integer.
#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
#else
typedef int NSInteger;
#endif
You can use NSInteger
any place you use an int
without converting it.