【发布时间】:2016-11-21 00:02:51
【问题描述】:
这是我的ViewControllerA 作为NSNotification 系统的一部分实现的方法:
- (NSInteger)updateTortoiseLevel:(NSNotification*)notification {
_updateValue = 0;
if ([notification.name isEqualToString:@"gameToTortoise"]) {
NSNumber* update = [notification.userInfo objectForKey:@"gameToTortoise"];
updateValue = [update integerValue];
} else {
// do other things
}
return _updateValue;
}
首先,我什至不知道我是否可以从这种方法返回任何东西,所以如果我不能,请告诉我。
这是我想要的:
- (void)viewWillAppear:(BOOL)animated {
if (_update == 1) {
[self runCellUpdates];
}
}
当我将ViewControllerB 弹出到A 时,我正在使用通知系统。首先会发生什么?...通知会在viewWillAppear: 之前发送吗?如果没有,我怎么能在viewWillAppear: 中使用updateTortoiseLevel:?
不要提及“改用委托设计模式”,因为我已经考虑过了,但它不适用于我当前的设计(至少 95% 确定)。干杯
【问题讨论】:
标签: objective-c uiviewcontroller nsnotificationcenter nsnotification viewwillappear