iPhone-从不同类别启动选择器

iPhone-从不同类别启动选择器,iphone,class,uitableview,selector,nsnotificationcenter,Iphone,Class,Uitableview,Selector,Nsnotificationcenter,我想从另一个名为“Properties”的类中重新加载另一个名为“WriteIt_MobileAppDelegate”的类中的表视图。我试图通过NSNotificationCenter类来实现这一点——调用日志,但从未更新表 h: [[NSNotificationCenter defaultCenter] postNotificationName:@"NameChanged" object:[WriteIt_MobileAppDelegate class]

我想从另一个名为“Properties”的类中重新加载另一个名为“WriteIt_MobileAppDelegate”的类中的表视图。我试图通过NSNotificationCenter类来实现这一点——调用日志,但从未更新表

h:

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

-(无效)从NIB中唤醒{

[[NSNotificationCenter defaultCenter]添加观察者:self 选择器:@selector(重新加载属性:) 名称:@“名称更改”对象:self]

}


我在这里做错了什么?

似乎您将
对象
参数用错了:

通知发送者
其 观察者想要的通知 接收
也就是说,只有通知 此发件人发送的邮件将被发送到 观察员。如果你通过零,那么 通知中心不使用 通知的发件人决定 是否将其交付给观察者


我不这么认为,[WriteIt\u MobileAppDelegate类]是唯一一个可以切换NSLog的对象。是否有其他方法切换选择器以更新tableview?是否已确认基础数据在到达reloadItProperties之前已更新?在该NSLog行中添加更新数据的日志记录。此外,在postNotificationName中,您可能希望使用
self
而不是
[WriteIt\u MobileAppDelegate class]
。是的,数据已更改。添加“self”没有任何作用,它只是阻止了NSLog的出现。我能以不同的方式调用选择器吗?虽然这不是问题,但在postNotificationName中,您可能需要self。然而,正如ChriB所提到的,在
addObserver
中,应该将对象参数从self更改为nil。有了self,您将只听取self(WriteIt)的通知。尽管它不能解释为什么会调用reloadItProperties。除了NameChanged的postNotificationName之外,还有其他调用reloadItProperties的代码吗?它现在可以工作了。DyingCactus,将其更改为nil,这一切都改变了。非常感谢!将您的评论作为答案发布,我会给您打绿色勾:)
- (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
}