objective-c - 找不到实例方法 - 对于应用程序委托(delegate)属性

标签 objective-c cocoa warnings appdelegate

好的,这是我的情况...

我的应用程序委托(delegate)声明如下:

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (assign) IBOutlet NSWindow *window;
@property (assign) ppDocumentManager* documentManager;

现在,我尝试从另一个位置访问 documentManager,如下所示:

AppDelegate* de = (AppDelegate*)[[NSApplication sharedApplication] delegate]; 
ppDocumentManager* docs = [de documentManager];

并且,在文件顶部,我还添加了 @class AppDelegate;,以便编译器知道 AppDelegate 代表什么。

效果很好。

<小时/>

但是,我不断收到警告:

Instance method '-documentManager' not found (return type defaults to 'id')

我应该怎么做才能消除所有警告?

最佳答案

好的,这对我有用:

  • 我决定在使用 documentManager.m 文件的开头使用 @class AppDelegate;,以避免循环引用的风险。

然而,事实证明这是没有必要的。

我刚刚导入了 AppDelegate.h,一切就位。

唷......

关于objective-c - 找不到实例方法 - 对于应用程序委托(delegate)属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14910353/

相关文章:

swift - URL 方案不适用于 macOS

iphone - 为什么这些方法会泄漏 NSDate 对象?

c - 在 C 中实现反向功能时出现段错误

visual-studio-2010 - 值不能为空

objective-c - 在 NSUserAutomatorTask 中设置变量

objective-c - cocoa编程中的区域码

objective-c - 是否有 Objective-C 中指针的终极指南?

objective-c - CLGeocoder 返回其他国家的位置

ios - UIImage 方面适合并对齐到顶部

php - Mysql_real_escape_string() 警告混淆