2

这是我的头文件

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <PolygonShape.h>

@interface Controller : NSObject {
    IBOutlet UIButton *decreaseButton;
    IBOutlet UIButton *increaseButton;
    IBOutlet UILabel *numberOfSidesLabel;
    //IBOutlet PolygonShape *shape;
}
- (IBAction)decrease;
- (IBAction)increase;
@end

这是我的实现文件

#import "Controller.h"

@implementation Controller
- (IBAction)decrease {
    //shape.numberOfSides -= 1;
}

- (IBAction)increase {
    //shape.numberOfSides += 1;
}
@end

为什么我的#import "Controller.h"线路上出现以下错误?

error: PolygonShape.h: No such file or directory

PolygonShape.h 和 .m 文件与 Controller 类位于同一项目和同一目录中。

4

3 回答 3

6

尖括号 ( <>) 表示文件位于标准包含路径中,例如 /usr/include 或 /System/Library/Frameworks。要导入相对于当前目录的文件,您需要像在#import "Controller.h".

于 2009-07-21T18:00:25.610 回答
1

系统头文件使用<>。你的头文件应该使用“”。

所以应该是:

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"

你可能想在你的头文件中使用@class PolygonShape 并在你的实现中进行导入。

于 2009-07-21T18:07:32.117 回答
0

如果您在 B 中导入 A 类,然后在 A 中导入 B 类,您将收到此错误

于 2011-09-16T12:25:08.827 回答