使用相对路径将自定义类 .h 文件导入 AppDelegate.h 不起作用
在我的 Cocoa 应用程序中,我创建了一个自定义视图类(NSView 的子类),名为“DragAndDropView”。它的 .h 和 .m 文件与 AppDelegate.h 放置在同一文件夹中。
在 AppDelegate.h 中,我需要声明 DragAndDropView 的出口。它看起来像这样:
#import <Cocoa/Cocoa.h>
#import <DragAndDropView.h>
@interface AppDelegate : NSObject <NSApplicationDelegate> {
@private
NSWindow *window;
DragAndDropView *dragAndDropView;
// Files
NSFileManager *fileMgr;
}
// Outlets
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet DragAndDropView *dragAndDropView;
@end
随着我的类的导入(#import),我出现以下错误:
'DragAndDropView.h' file not found
有人知道如何修复它吗?
In my Cocoa Application I have created a Custom View Class (subclass of NSView), named "DragAndDropView". Its .h and .m files are placed in the same folder than the AppDelegate.h.
Into the AppDelegate.h, I need to declare an outlet of my DragAndDropView. It looks like this:
#import <Cocoa/Cocoa.h>
#import <DragAndDropView.h>
@interface AppDelegate : NSObject <NSApplicationDelegate> {
@private
NSWindow *window;
DragAndDropView *dragAndDropView;
// Files
NSFileManager *fileMgr;
}
// Outlets
@property (assign) IBOutlet NSWindow *window;
@property (assign) IBOutlet DragAndDropView *dragAndDropView;
@end
With the import of my class (#import ), I become the following error:
'DragAndDropView.h' file not found
Anyone knows how can I fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在导入行中使用引号而不是尖括号。即:而不是
:
本质上,前者用于从项目中导入标头,后者用于从系统库中导入标头。
You need to use quotes instead of angled brackets in your import line. i.e. this:
instead of this:
In essence, the former is for importing headers from your project, the latter is for importing headers from system libraries.