2

It is my GameEngine.h:

#import <Foundation/Foundation.h>
#import "GameArray.h";


@interface GameEngine : NSObject {
    GameArray *gameButtonsArray;
}

@property (nonatomic, retain) GameArray *gameButtonsArray;

And this is my GameArray.h:

#import <Foundation/Foundation.h>
#import "MyAppDelegate.h";

@interface GameArray : NSObject {
    NSMutableArray *gameButtonsArray;

}
@property (nonatomic, retain) NSMutableArray *gameButtonsArray;

It keep prompt my "expected specifier-qualifier-list" error i my GameEngine.h, and error said that "expected specifier-qualifier-list before 'GameArray'", what's going on?

Tattat
  • 15,548
  • 33
  • 87
  • 138
  • I changed my "gameButtonsArray" in GameArray.h to myGameButtonsArray, it also prompt this error. – Tattat Apr 11 '10 at 07:43

3 Answers3

4

This is the best practice.

GameEngine.h

#import <Foundation/Foundation.h>

@class GameArray;

@interface GameEngine : NSObject {
    GameArray *gameButtonsArray;
}

@property (nonatomic, retain) GameArray *gameButtonsArray;

Then in GameEngine.m

#import "GameEngine.h"
#import "GameArray.h"

@implementation GameEngine    
//...
@end

This prevents circular references wherein one header imports a second header which imports the first which imports the second and so on in an endless cycle.

TechZen
  • 64,370
  • 15
  • 118
  • 145
2

Lose the semi-colon on line 2 in your .h file

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
Paul Lynch
  • 19,769
  • 4
  • 37
  • 41
0

If removing the unnecessary semicolons does not fix your problem, most likely MyAppDelegate.h imports GameEngine.h creating a circular dependency between the GameEngine.h and GameArray.h. Try removing the #import "GameArray.h" from GameEngine.h and replacing it with:

@class GameArray;

Also add

#import "GameArray.h"

to GameEngine.m below the import of GameEngine.h

JeremyP
  • 84,577
  • 15
  • 123
  • 161