NSMapTable missing from 3.0 headers?

戏子无情 提交于 2019-12-08 13:38:58

问题


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:


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.



来源:https://stackoverflow.com/questions/1095368/nsmaptable-missing-from-3-0-headers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!