Sunday, September 29, 2013

OC in NSInteger and int differ ah?

Why are some places NSInteger not replaced int? ? ? ?
Reply:
Specifically what went wrong?
NSInteger is the object and int is the basic data types, not objects.

Reply:
Blind say, NSInteger is not an object!
Depending on the platform, NSInteger sometimes int, sometimes long

As to the question can not be transferred, it should be set strict compiler

Reply:
When you need to use a variable of type int, I like to write C programs can be the same, with int, you can also use NSInteger, but more is recommended NSInteger, because it would not consider the equipment is 32-bit or 64-bit.
Landlord you can see the following definition:
# If __ LP64__ | | (TARGET_OS_EMBEDDED &&! TARGET_OS_IPHONE) | | TARGET_OS_WIN32 | | NS_BUILD_32_LIKE_64
typedef long NSInteger;
typedef unsigned long NSUInteger;
# Else
typedef int NSInteger;
typedef unsigned int NSUInteger;
# Endif


Reply:
Depending on the platform, nsinterger is 4 bytes

No comments:

Post a Comment