【发布时间】:2009-09-30 08:34:24
【问题描述】:
我刚刚在 XCode 3.2 上创建了一个新的 Cocoa 项目。我在 Snow Leopard 中运行它。
当我为 10.6 构建它时,它工作正常,但如果我将活动 SDK 更改为 10.5,我会收到此错误:
cannot find protocol declaration for 'NSApplicationDelegate'
【问题讨论】:
标签: xcode osx-leopard target
我刚刚在 XCode 3.2 上创建了一个新的 Cocoa 项目。我在 Snow Leopard 中运行它。
当我为 10.6 构建它时,它工作正常,但如果我将活动 SDK 更改为 10.5,我会收到此错误:
cannot find protocol declaration for 'NSApplicationDelegate'
【问题讨论】:
标签: xcode osx-leopard target
NSApplicationDelegate 是一个new protocol as of 10.6。您收到错误消息(我猜)是因为您的应用程序委托正在实现此协议。我不确定这是否是最佳实践,但您可以考虑使用预处理器来帮助您:
#if (MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5)
@interface MyAppDelegate : NSObject
#else
@interface MyAppDelegate : NSObject <NSApplicationDelegate>
#endif
【讨论】: