NSMapTable 3.0标头中缺少? [英] NSMapTable missing from 3.0 headers?

查看:57
本文介绍了NSMapTable 3.0标头中缺少?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在必须同时在3.0和2.2.1下运行的程序中使用NSMapTable.正如预期的那样,该程序在2.2.1库中编译时没有问题,但是当我切换到3.0时,出现编译器错误:

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'

换句话说,XCode找不到NSMapTable类的声明.我必须在自己的标头中添加前向声明(@class 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>

在我的实现文件中,以便能够使用NSMapTable.

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?

(我应该指出,我的确在使用NSMapTable的类的头文件中具有#import,但仍需要特定的导入.)

(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.)

推荐答案

我也不认为NSMapTable在2.2上可用于为设备"编译的应用程序.它仅在"Simulator"上可用.由于3.0的模拟器可以更准确地表示设备,因此该标头不再可用.幸运的是,您可以使用NSDictionary以及围绕键和值的适当的NSValue或NSNumber包装对象来完成NSMapTable的大部分工作.

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.

这篇关于NSMapTable 3.0标头中缺少?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆