我刚刚在 XCode 3.2 上创建了一个新的 Cocoa 项目。我在 Snow Leopard 中运行它。
当我为 10.6 构建它时,它工作正常,但如果我将活动 SDK 更改为 10.5,我会收到此错误:
cannot find protocol declaration for 'NSApplicationDelegate'
我刚刚在 XCode 3.2 上创建了一个新的 Cocoa 项目。我在 Snow Leopard 中运行它。
当我为 10.6 构建它时,它工作正常,但如果我将活动 SDK 更改为 10.5,我会收到此错误:
cannot find protocol declaration for 'NSApplicationDelegate'
NSApplicationDelegate 是10.6 的新协议。您收到错误(我猜)是因为您的应用程序委托正在实现此协议。我不确定这是否是最佳实践,但您可能只是考虑使用预处理器来帮助您:
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
@interface MyAppDelegate : NSObject
#else
@interface MyAppDelegate : NSObject <NSApplicationDelegate>
#endif