dontWatchMyProfile
dontWatchMyProfile

Reputation: 46370

Can I safely store UInt32 to NSInteger?

Is an NSInteger big enough for UInt32? Or is it even the same thing?

Upvotes: 0

Views: 649

Answers (2)

jessecurry
jessecurry

Reputation: 22116

Here is code from NSObjCRuntime.h (from the iPhone SDK 3.2 install):

#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

Upvotes: 1

Ole Begemann
Ole Begemann

Reputation: 135568

No because NSInteger is a signed type while UInt32 is unsigned.

You should inspect the definitions of these types in Apple's header files to understand what they mean. It's very easy to do so. From an open project in Xcode, select File -> Open Quickly... (Command-Shift-D) and type the type name you are interested in into the text field. It will find the file where it is defined. Or just Command-double click a type in your source code.

Upvotes: 2

Related Questions