On Sep 18, 2010, at 9:29 AM, Richard Somers wrote:

> On Sep 18, 2010, at 9:36 AM, Raleigh Ledet wrote:
> 
>> Define "lots". 10 or 100? Generally, you create a nib for each view and you 
>> programmatically load the nib with a view controller.
> 
> Lots means 20 initially, up to 80 total later on.
> 
>> If variations are minor, then you can reduce the number of nibs to just the 
>> major layout differences and in your custom viewController class 
>> programmatically hide/show/modify just the minor differences. In general, I 
>> find doing most of the work in IB and making minor adjustments 
>> programmatically is a lot easier than doing everything programatically.
> 
> Very interesting concept, thanks for sharing this. So my application has 20 
> to 80 what I will call "view representations". Many of the variations are 
> minor from one representation to another. Some are, well, not so minor. One 
> reason for my having each view representation as a separate object is that 
> state is easily maintained. Each view representation is put into a certain 
> state by the user. When the user leaves a particular view representation and 
> then returns the state must be restored. This is readily accomplished by 
> having each view representation as a stand alone view object. I think this 
> might be more difficult it there was only a single view object for all 
> representations.

Ah, I see. Then you were not aware that if you can load a nib multiple times to 
create multiple instances of the same view hierarchy. You can set the bindings 
up in IB to the "File's Owner" (which you need to set it's subclass to 
NSViewController) . representedObject. Then when you load the nib with a new 
NSViewController instance, you set the representedObject and the rest is done 
for you. Now you have two NSViewController instances that each have their own 
but identical view hierarchies which display information for two different 
representedObjects. 

You can probably set up bindings to the hidden property of vies and controls to 
automatically make those minor changes. Again, saving you from having to write 
more code.

-raleigh

> 
>> You can even use this tip recursively if that helps. That is, load a custom 
>> view that contains another custom view that you must load from another nib.
> 
> Yes I can see this. This is perhaps what Apple is doing with their stack 
> views in the Inspector pane in Interface Builder. One view, loads another 
> view, which loads another view, and so on.
> 
> Thanks for your comments.
> 
> --Richard
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to