Re: Ideas for multi-type inspector design
Re: Ideas for multi-type inspector design
- Subject: Re: Ideas for multi-type inspector design
- From: Graham Cox <email@hidden>
- Date: Wed, 16 Dec 2009 11:08:44 +1100
On 16/12/2009, at 7:38 AM, Mads Paulin wrote:
> I am able to get the infrastructure of the inspector up and running and also
> able to make a NIB file and an NSWindowController subclass for each object
> type to go into the inspector. Where I need some input is on how to
> determine which of these controllers are activated when the selection in the
> OutlineView changes so that the correct NIB can be swapped into the
> inspector window ?
>
> - One solution is to hold a dictionary mapping some kind of type-id to the
> appropriate WindowController-pointer. Surely this is not a nice solution as
> this dict must be changed when new types are created in later versions of
> the app - either manually or by a bundle-loading-like approach.
>
> -Also, the dataobjects should not "know" about their respective
> inspector-panel/controller as this will violate the MVC pattern.
>
> Any ideas or thougts are greatly appreciated.
I've done this using a naming convention of my own devising, based on the classname. So you could get the object's class, convert it to a string using NSStringFromClass(), append some other stuff if you want and look that up as the nib name. It's extensible without coding changes, though you'll probably want to build in some protection against having the nib not found and so on. Also, some simple protocol (or base class) shared by all the loaded controllers will allow the loader to treat them all equally, in terms of getting the view to be installed in the window and passing the object to be inspected to it.
--Graham
_______________________________________________
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