我有一个奇怪的问题。在ViewController.m
,我成功保存后发布通知,并执行塞格到ListViewController
。在ListViewController.m
,我设立了观察员在viewDidLoad
并且申报处理的方法。即使正确调用方法,NSNotification处理程序方法内部也没有执行任何代码
问题是处理程序方法被调用,但没有执行代码!任何想法为什么?
// ViewController.m
if (success) {
[[NSNotificationCenter defaultCenter] postNotificationName:kAHPlistSavedSuccessfully object:self];
[self performSegueWithIdentifier:kAHDetailToListSegue sender:self];
}
// ListViewController.m
- (void)viewDidLoad
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(plistSavedSuccessfully:) name:kAHPlistSavedSuccessfully object:nil];
}
- (void)plistSavedSuccessfully:(NSNotification *)notification
{
NSLog(@"notification %@", notification);
[self someMethod]; // not called !
}
这是来自plistSavedSuccessfully的日志消息:notif = NSConcreteNotification 0x1f5406f0 {name = plistSavedSuccessfully; object =} –
alexhajdu
2013-02-13 23:43:07
如果是打印NSLog,它也应该执行'someMethod'。 someMethod内部是什么?你有没有尝试在其中添加NSLog并检查? – iDev 2013-02-13 23:44:06
@ACB是的,NSLog中someMethod的作品,但如果我尝试修改ListViewControllers插座它不起作用 – alexhajdu 2013-02-13 23:54:04