views:

524

answers:

1

I'm using NSMapTable in a program that must run under both 3.0 and 2.2.1. As expected, the program compiles without problems for the 2.2.1 libraries, but when I switch to 3.0, I get compiler errors:

error: expected specifier-qualifier-list before 'NSMapTable'

In other words, XCode can't find the declaration of the NSMapTable class. I had to put in a forward declaration (@class NSMapTable) in my own header and

#import <Foundation/NSMapTable.h>

in my implementation file in order to be able to use NSMapTable.

Any explanations for this? Or is it just a bug, plain and simple?

(I should point out that I do, of course, have #import in the header file of the class that uses NSMapTable, but still need the specific import.)

+1  A: 

I don't believe NSMapTable was available on 2.2 for apps compiled for "Device", either; it was only available on "Simulator". Since 3.0's simulator is a more accurate representation of the device, that header is no longer available. Fortunately, you can do much of what an NSMapTable can do with an NSDictionary and appropriate NSValue or NSNumber wrapper objects around keys and values.

Brent Royal-Gordon
Thanks. A clear sign that I should be less lazy about testing on a device often. But why did it compile for 3.0 simulator when I put in the extra #include?
Felixyz
Brent Royal-Gordon