Nella mia applicazione ci sono due viewControllers come FirstViewController
e DetailViewController
. Quando si tocca una cella di tabella, si sposta su DetailViewController
. In DetailViewController
, voglio modificare e ricaricare la vista tabella FirstViewController
Come utilizzare NSNotification
Come posso utilizzare NSNotification
per questo problema?
Ecco il metodo che voglio implementare NSNotification
roba
-(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];
}
Può essere utile a voi http://mac-objective-c.blogspot.com/2009/02/nsnotifications-broadcasting-mechanism.html – Tendulkar
Questo non è un compito per una notifica. Dai un'occhiata a TableViewProgrammingGuide. È possibile iniziare qui: http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/TableView/Introduction/Introduction.html HTH –
Suggerirei, è preferibile utilizzare il modello delegato piuttosto che la notifica. –