Reputation: 144
In my application, I have a NSWindow
that has a NSTableView
object and a few buttons. When the user presses the "new" button, an "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!
Upvotes: 1
Views: 630
Reputation: 197
You can subclass the NSWindow and override the following method:
- (void)becomeKeyWindow
Upvotes: 0
Reputation: 2356
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];
}
Upvotes: 1