日々精進

新しく学んだことを書き留めていきます

UIViewController初期化で不具合

以下のようなコードを書いたらViewとControllerの参照関係がおかしくなった。

- (void)viewDidLoad {
    [super viewDidLoad];
    if (self.delegate){
        self.currerntViewController = [[ChartGridViewController alloc] initWithView:self.chartGridView];
        self.switchViewController = [[ChartGridViewController alloc] initWithView:self.chartGridView];
    }
}

initWithViewで同じViewインスタンスを渡してるから、二つのControllerが同じViewを参照してしまっている。これに気付かずかなり困った。。