iPhone - 启动不同类别的选择器
我想重新加载一个表视图,该视图位于另一个名为“WriteIt_MobileAppDelegate”的类中,该类来自我的其他类(称为“Properties”)。我尝试通过 NSNotificationCenter 类来执行此操作 - 日志被调用但表从未更新。
Properties.h:
[[NSNotificationCenter defaultCenter] postNotificationName:@"NameChanged"
object:[WriteIt_MobileAppDelegate class]
userInfo:nil];
WriteIt_MobileAppDelegate.m
-(void)awakeFromNib {
[[NSNotificationCenter defaultCenter] addObserver:self 选择器:@selector(reloadItProperties:) 名称:@“NameChanged”对象: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
}
我在这里做错了什么
I'd like to reload a table view which is in another class called "WriteIt_MobileAppDelegate" from one of my other classes which is called "Properties". I've tried to do this via the NSNotificationCenter class - the log gets called but the table is never updated.
Properties.h:
[[NSNotificationCenter defaultCenter] postNotificationName:@"NameChanged"
object:[WriteIt_MobileAppDelegate class]
userInfo:nil];
WriteIt_MobileAppDelegate.m
-(void)awakeFromNib {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(reloadItProperties:)
name:@"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
}
What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
似乎您使用的
object
参数错误:addObserver:selector:name:object:
Seems like you are using the
object
parameter wrong:addObserver:selector:name:object: