Reputation: 5086
I have one NSTableView
nib that contains a number of cells that will be reused throughout 3 different NSViewControllers
. The NSTableView
and cells function in the same way and look similar but present different data in each of the different views.
Right now I can set the File's Owner to one of the NSViewController
classes, but not all of them meaning I'd have to duplicate the nib 3 times. Given that I'm loading with initWithNibName:bundle
I don't see any way to set the File's Owner first either.
How can I use one nib with multiple File's Owner
for NSViewControllers
?
Any ideas?
Upvotes: 1
Views: 127
Reputation: 12782
Have you tried simply NSViewController or a subclass of it that is an abstract superclass of your view controllers?
One subclass could even be sufficient if the differences between your instances can be managed with conditional logic in the subclass.
Either way, it sounds like you have some refactoring to do, but minimal.
Upvotes: 1
Reputation: 1097
I am an iOS developer not OSX but we also face this problem. In our case I would have used a UIView class(surely you will have NSView kind of class) and then added table on that class and made File's Owner of the table to that view class.
I can reuse this class whenever I want in any view controller by adding this view on that controller and changing its data set.
Upvotes: 0