Reputation: 35953
I have a core data value that is "integer 32". How should I set/get values from this?
with
[NSNumber numberWithInteger:X]
or with
[NSNUmber numberWithInt:X]
?
Upvotes: 3
Views: 1620
Reputation: 39296
As Jack said, it's a typedef. To add on to the answer, here's how you find out.
In XCode, hold down Apple key with your source file open. You'll see NSInteger become a link. After clicking on it, it will open it's 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
Also, xlc0212's point is a good one. If you read the definition above, it's pretty clear.
Upvotes: 8
Reputation: 10772
NSInteger
is simply a typedef
for int
, so you don't lose/gain integer precision one way or another. Both will work.
Upvotes: 6