好的,这是我的情况...
我的应用程序委托(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/