我有以下代码:
- (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);
}];
}
其中分配 GameViewController 呈现它,然后分配 Game 对象。最后,它会调用您的块来执行特定于游戏类型的初始化
我已经阅读了有关 Blocks 的内容,它在 gameviewcontroller loadView 之后触发了该块我希望代码以与现在相同的方式运行,但没有当前视图请帮助