【发布时间】:2023-03-21 05:40:02
【问题描述】:
我有点困惑如何设置一个比最顶层低两级的课程。
例如,假设我有一个名为 BoardGame 的游戏。 numberOfSquares 中的参数之一。
类的设置如下:
BoardGameSetupViewController > BoardGamePlayViewController > GameEngine
BoardGameSetupViewController 在选择完方格数后创建 BoardGamePlayViewController 的实例。 BoardGamePlayViewController 将 GameEngine 类作为 @property 进行了@synthesised。
那么我将如何直接从 BoardGameSetupViewController 设置 GameEngine?例如设置 numberOfSquares?
所以在 BoardGameSetupViewController 中,我想设置引擎的属性,但似乎没有传递下去。
BoardGamePlayViewController *boardGamePlayViewController = [[BoardGamePlayViewController alloc] initWithNibName:@"BoardGameView" bundle:nil];
// this line doesn't work
boardGamePlayViewController.gameEngine.numberOfSquares = 12;
【问题讨论】:
标签: iphone objective-c properties class