I've got this code in my viewController.m file
- (void)viewDidLoad {
[super viewDidLoad];
GameLogic *_game = [[GameLogic alloc] init];
[_game initGame];
.......
}
GameLogic is another class which I created. in the same viewController.m file, I have got another function
- (void)test {
if([_game returnElecFence]) //[_game returnsElecFence] causes the error
{
NSLog(@"YES");
}
else {
NSLog(@"NO");
}
.......
}
Problem is, whenever the test function is called, I get an error saying '_game' undeclared. I tried putting the GameLogic init code in the .h file and on top of the @implementation to make it global but every method I tried resulted in a worse error. TIA to anyone who can suggest some ideas to clear this error up