每當我構建下面的代碼,我得到上面的錯誤。錯誤:在目標C之前的預期說明符 - 限定符列表?
//Controller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"
#import "PolygonView.h";
@interface Controller : NSObject
{
IBOutlet UIButton *decreaseButton;
IBOutlet UIButton *increaseButton;
IBOutlet UILabel *numberOfSidesLabel;
IBOutlet PolygonShape *shape;
IBOutlet PolygonView *shapeView;
}
- (IBAction)decrease;
- (IBAction)increase;
- (void)awakeFromNib;
@end
//Controller.m
#import "Controller.h"
@implementation Controller
@end
但是,當我替換導入語句,並將一個轉發類引用,而不是代碼編譯。
//Controller.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import "PolygonShape.h"
@class PolygonView;
@interface Controller : NSObject
{
IBOutlet UIButton *decreaseButton;
IBOutlet UIButton *increaseButton;
IBOutlet UILabel *numberOfSidesLabel;
IBOutlet PolygonShape *shape;
IBOutlet PolygonView *shapeView;
}
- (IBAction)decrease;
- (IBAction)increase;
- (void)awakeFromNib;
@end
//Controller.m
#import "Controller.h"
#import "PolygonView.h"
@implementation Controller
@end
任何人都可以解釋一下嗎?
PolygonShape和PolygonView可能具有周期性導入。這就是前瞻性聲明存在的原因。請使用它們。 – 2009-08-07 19:19:29
PolygonShape和PolygonView沒有循環導入,但是PolygonView和Controller沒有。謝謝您的幫助! – Ridwan 2009-08-07 19:25:26
@Jason:這可能會是一個很好的答案。 – Chuck 2009-08-07 19:25:27