Trong đơn đăng ký của tôi, có hai viewControllers là FirstViewController
và DetailViewController
. Khi nhấn vào ô bảng, nó điều hướng đến DetailViewController
. Trong DetailViewController
, tôi muốn chỉnh sửa và tải lại chế độ xem bảng của FirstViewController
Cách sử dụng NSNotification
Tôi làm cách nào để sử dụng NSNotification
cho sự cố này?
Dưới đây là phương pháp tôi muốn thực hiện NSNotification
thứ
-(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];
}
Có thể hữu ích cho bạn http://mac-objective-c.blogspot.com/2009/02/nsnotifications-broadcasting-mechanism.html – Tendulkar
Đây không phải là nhiệm vụ để thông báo. Chỉ cần nhìn vào TableViewProgrammingGuide. Bạn có thể bắt đầu tại đây: http://developer.apple.com/library/mac/#documentation/cocoa/Conceptual/TableView/Introduction/Introduction.html HTH –
Tôi khuyên bạn nên sử dụng mẫu đại biểu hơn là thông báo. –