I’m new to Objective-c, so sorry if I’m missing something really obvious. I’m currently coding a game that incorporates lots of mini games. I’ve built a
SuperGameController
subclass of UIViewController, and then have all my games as subclasses of this. The SuperGame Controller has a number of variables defined in the interface as follows,
@interface SuperGameController : UIViewController {
MainViewContoller *mainView;
bool GAME_PLAYING;
bool PAUSED;
bool WIN;
ball *theBall;
UIImage *mainBall;
UIImageView *ballView;
}
and as such, (I’m told) I don’t need to define these variables in the header file of each individual game. I’ve built a few of these mini games and they work on the iPhone 4.3 Simulator, but when I try to Run the project on my iPhone, it tells me that each of these variables is
undeclared (first use in this function)
Is there something I need to do to make sure the project runs on the iPhone or am I just missing something obvious here? I’ve played around a lot and haven’t found anything that helps. Any help you could give would be amazing!!
Thanks!!
There seems to be an XCode bug – it compiles it fine for the simulator, but not for the device.
Use self->[name] as a workaround (e.g. self->theBall, self->GAME_PLAYING, etc.)
Edit: to clarify, that is assuming you don’t use properties but the ivars directly. If you make properties out of theBall, GAME_PLAYING, etc., use self.[property] (i.e. dot, not the ->).