Re: NSTableView with PopUpButtonCell column with different content per row
Re: NSTableView with PopUpButtonCell column with different content per row
- Subject: Re: NSTableView with PopUpButtonCell column with different content per row
- From: Quincey Morris <email@hidden>
- Date: Thu, 18 Feb 2010 13:30:25 -0800
On Feb 18, 2010, at 12:38, Sean McBride wrote:
> I'm looking for some pointers on how to have a TableView where one
> column uses a PopUpButtonCell who's contents need to be different for
> different rows.
>
> A contrived example:
>
> OS Name OS Version
> <popup: Mac/Win> <popup: 10.4/10.5 OR Vista/7>
>
> So in the 'OS Version' column, I want the popup's contents to be either
> one list or another list depending on 'OS Name' of any given row.
Aside from what Kyle suggested (adjusting the menu dynamically "in" the interface), you could simply have your window controller provide an array property with version strings for the current OS (along with a KVO dependency to keep the property in sync with the current OS), and bind the popup content to that array.
However, I'd suggest that perhaps you're asking the wrong question -- there might be a deeper data model design issue.
Presumably your data model would have an "OS" property (maybe an integer constant, maybe a string, maybe an object) and a "version" property (ditto). It seems to me it's up to the data model to specify which are the valid versions for each OS value, otherwise how can the data model validate itself? The consequence would be that it's the data model's responsibility to supply the arrays [of integers/strings/objects] that ultimately allow you to populate your popups appropriately. It would then be up to the window controller (or perhaps a view) to transform the pure data model information into the properties that the interface needs for binding purposes.
Without that, the danger is that your data model depends for its correctness on its internal rules being re-implemented correctly in the view portion of your design. That would likely be an abuse of the MVC pattern.
FWIW.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden