使用相对路径将自定义类 .h 文件导入 AppDelegate.h 不起作用

发布于 2024-12-21 17:52:06 字数 690 浏览 1 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余厌 2024-12-28 17:52:06

您需要在导入行中使用引号而不是尖括号。即:而不是

#import "DragAndDropView.h"

#import <DragAndDropView.h>

本质上,前者用于从项目中导入标头,后者用于从系统库中导入标头。

You need to use quotes instead of angled brackets in your import line. i.e. this:

#import "DragAndDropView.h"

instead of this:

#import <DragAndDropView.h>

In essence, the former is for importing headers from your project, the latter is for importing headers from system libraries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文