error: expected specifier-qualifier-list before...in Objective C ?

Posted by Ridwan on Stack Overflow See other posts from Stack Overflow or by Ridwan
Published on 2009-08-07T19:16:56Z Indexed on 2010/05/06 10:08 UTC
Read the original article Hit count: 490

Filed under:
|
|

Hi guys. Whenever I build the following code, I get the error above.

//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

However, when I replace the import statement and put a forward class reference instead, the code compiles.

//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

Can anyone explain?

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone