Forums > Dev

again: problem with declaring a NSInteger

September 12, 2010 | 7:57 pm

Hi again,

I have added all the frameworks required by a Cocoa Application (AppKit.framework, Cocoa.framework, CoreData.framework, Foundation.framework) to my external, but when I try to declare a NSInteger;

NSInteger myNSInt

I receive an error: ‘NSInteger’ undeclared (first use in this function).

I can’t explain this problem; especially because of the fact that I can use all other NS classes. Why not NSInteger?


September 13, 2010 | 7:07 pm

Chances are you are using the 10.4 SDK. configuring it to use the 10.5 SDK can be a pain, but perhaps Tim can shed light on this if necessary. Otherwise, you might be fine just using NSNumber.

-Joshua


September 14, 2010 | 7:53 pm

Well, I am using MaxSDK 5.0.6

Rainer


September 14, 2010 | 8:31 pm

I was referring to the OS SDK, for which NSInteger only exists in the 10.5 SDK or later. This is really a trivial typedef, and if you need it without using the 10.5 SDK or later, you can simply use the following:

#if __LP64__ || TARGET_OS_EMBEDDED || TARGET_OS_IPHONE || TARGET_OS_WIN32 || NS_BUILD_32_LIKE_64
typedef long NSInteger;
#else
typedef int NSInteger;
#endif

http://developer.apple.com/library/mac/#documentation/cocoa/reference/foundation/Miscellaneous/Foundation_DataTypes/Reference/reference.html


Viewing 4 posts - 1 through 4 (of 4 total)