English 中文(简体)
iPhone - Launching selectors from a different class
原标题:

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?

最佳回答

Seems like you are using the object parameter wrong:

addObserver:selector:name:object:

notificationSender
The object whose notifications the observer wants to receive;
that is, only notifications sent by this sender are delivered to the observer. If you pass nil, the notification center doesn’t use a notification’s sender to decide whether to deliver it to the observer.

问题回答

暂无回答




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签