I have the following code:
- (void)startGameWithBlock:(void (^)(Game *))block
{
GameViewController *gameViewController = [[GameViewController alloc] initWithNibName:@"GameViewController" bundle:nil];
gameViewController.delegate = self;
[self presentViewController:gameViewController animated:NO completion:^
{
Game *game = [[Game alloc] init];
gameViewController.game = game;
game.delegate = gameViewController;
block(game);
}];
}
Which allocate the GameViewController
present it, and then allocate the Game object.
Finally, it calls your block to do the game-type specific initializations
I have read about Blocks and It is fire the block after the gameviewcontroller loadView
I want the code run in the same way as it is now but with out present the view please help
If I understand you right, you simply do not want to present the
gameViewController. So you want to do this:There are two issues with this.
gameViewControllerso it would be deallocated again. You could solve this by defining a property in whatever view controllerselfrefers to and assigning to that.block-call could include code that depends ongameViewControllerto be shown. If this is not the case, you should be fine.Hope this helps.