views:

64

answers:

1

I got an application which has a NSToolbar in its main window. Depending on which icon is clicked a NSView is displayed in this window. My problem is, that one of these views shows data in a NSTableView that I want to be reloaded each time the view is visible. Since -init is only called once, I don't know how to do that. (example: When the application starts it shows the Documents section [on of the sub views of the window]. Now when I click on Employees [which displays another sub view instead of the first one] and then on Documents again, I want the data in Documents' NSTableView to reload.)

How do I do that?

Thanks in advance.

+1  A: 

I got an application which has a NSToolbar in its main window. Depending on which icon is clicked a NSView is displayed in this window.

Use a tab view. You can hide the tabs, then implement your action methods for the toolbar items to act as the tabs, changing the selected tab view item to whichever one corresponds to the pressed toolbar item.

Now when I click on Employees [which displays another sub view instead of the first one] and then on Documents again, I want the data in Documents' NSTableView to reload.

Why? Why not reload it only when the data changes?

You don't have to hold NSTableView's hand; if it needs the data from you again, it'll ask you for it again.

And if you're concerned about reloading the data while the view is not visible, that's premature optimization. Don't worry about it until you prove via profiling that it is a real performance problem.

Peter Hosey
Yep, and generally NSTableView is very good about not refreshing when it's not visible.
Rob Keniger