我想重新加载一个表视图,该表视图来自另一个称为“ properties”的类,称为“ writeit_mobileappdelegate”。我尝试通过NSNotificationCenter类来执行此操作 - 日志被调用,但该表从未更新。

properties.h:

 [[NSNotificationCenter defaultCenter] postNotificationName:@"NameChanged"
              object:[WriteIt_MobileAppDelegate class]
               userInfo:nil]; 

writeit_mobileappdelegate.m

- (void)awakefromnib {

[nsnotificationcenter defaultCenter] addobserver:self Selector:@selector(reloAditProperties :)名称:@@“ namechanged” object:self];

}

- (void) reloadItProperties: (NSNotification *)notification {

 NSLog(@"Reloading Data"); //this gets called
[[self navigationController] dismissModalViewControllerAnimated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
 [self.tblSimpleTable reloadData];
 [self.tblSimpleTable reloadSectionIndexTitles];
 // but the rest doesn't
}

我在这里做错了什么?

有帮助吗?

解决方案

好像您正在使用 object 参数错误:

Addobserver:选择器:名称:对象:

通知者
观察者想要接收的通知的对象;
也就是说,只有该发件人发送的通知才传递给观察者。如果您通过了零,则通知中心不会使用通知的发件人来决定是否将其交付给观察者。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top