在我的應用程序中有兩個viewControllers作爲FirstViewController
和DetailViewController
。 當點擊一個表單元格時,它導航到DetailViewController
。在DetailViewController
中,我想編輯並重新加載FirstViewController
的表格視圖如何使用NSNotification
如何使用NSNotification
解決此問題?
這是我想要實現NSNotification
東西
-(IBAction) save{
strSelectedText=theTextField.text;
[NSNotificationCenter defaultCenter];
NSNotification* notification = [NSNotification notificationWithName:@"MyNotification" object:self];
[[NSNotificationCenter defaultCenter] postNotification:notification];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector (objFirstViewController) name:@"MyNotification" object:nil];
[self.navigationController popViewControllerAnimated:YES];
}
這可能是你http://mac-objective-c.blogspot.com/2009/02/nsnotifications-broadcasting-mechanism.html – Tendulkar
這個有用的是不是一個通知的任務。只需查看TableViewProgrammingGuide。你可以從這裏開始:http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/TableView/Introduction/Introduction.html HTH –
我建議,你最好使用委託模式而不是通知。 –