我正在尝试运行以下代码,除非NSNotification发送了 a 。我不知道如何将NSNotificationif 语句放入:
if (!self.subViewControllerProv) {
self.subViewControllerProv = [[ProvViewController alloc] init];
}
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleNotification:) name:@"SomeNotification" object:nil];
回顾一下:如果观察到了NSNotification消息,那么如果没有观察到alloc则init不要ProvViewController。