Let me first frame my situation. I have a ViewController, which retains an instance of a GameManager
. The GameManager
class encapsulates the state and logic of a simple game. When certain states are encountered in the GameManager
, I would like to perform a set of actions. For instance: when a game is over, I would like to display a game over dialog. As mentioned above, the game logic resides in the GameManager
, but the method to create and position a new 'game over' dialog resides in the ViewController. To allow for the GameManager
to 'call' back into the ViewController, I passed a reference to the ViewController to the GameManager
when allocated, and simply invoke methods on the ViewController. For example:
// GameManager.m
- (void) gameOver {
[self.viewController showGameOver];
}
My question is: Is this the proper, objective-c way to do this? Is there a purer way to handle this? I've though using blocks may be more appropriate.