XCode, error: '_object' undeclared. Need some help solving this problem

Posted by user309030 on Stack Overflow See other posts from Stack Overflow or by user309030
Published on 2010-04-07T04:51:12Z Indexed on 2010/04/07 4:53 UTC
Read the original article Hit count: 278

Filed under:
|

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])
    {
        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

© Stack Overflow or respective owner

Related posts about xcode

Related posts about error