In my application, I have a NSWindow
that has a NSTableView
object and a few buttons. When the user presses the "new" button, 开发者_如何学Goan "ItemAdd" NSWindowController
is activated where the user types in attributes for the item to be added to the NSTableView
.
My question is this: since NSTableView
requires reloadData
to update its view, how do I call reloadData
after the ItemAdd window closes and focus shifts back to the NSWindow with the NSTableView
.
Thanks for the help!
You could put reload data in a notification handler:
Put this in an initialization method of an object that you want the notification to get called on:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didBecomeMainWindow) name:@"NSWindowDidBecomeKeyNotification" object:nil];
Then make a method something like this:
- (void) didBecomeMainWindow
{
[tableView reloadData];
}
You can subclass the NSWindow and override the following method:
- (void)becomeKeyWindow
精彩评论