2009-07-21 60 views
2

这里是我的头文件为什么我的目标C实现文件承认我的import语句

#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类相同的项目和目录中。

+0

您确定PolygonShape文件已添加到目标中吗? – teabot 2009-07-21 18:00:37

回答

6

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

+0

我虽然也是,但我只是用尖括号在本地文件上试过,它似乎工作正常。 – teabot 2009-07-21 18:01:39

1

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

所以它应该是:

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

,你可能想在你的头文件@class PolygonShape使用,做进口在您的实现。

0

如果您在B中导入A类,然后在A中导入B类,则会出现此错误

相关问题