On 05/01/2010, at 11:45 AM, Dan wrote:

> My end goal is to have an interface that swaps views and performs actions at 
> each of those views, with the ability to go back and forth over those views. 
> Not sure how to do this I found something similar to what I want to do in 
> View swapping using a view controller. So I have a Main Window, that contains 
> a NSView aka the right side of a vertical split view object and I have set up 
> a situation using multiple xib interfaces containing views to swap.
> 
> Using an NSViewController object by following the example 
> (http://developer.apple.com/mac/library/samplecode/ViewController/). This 
> issue I am running into is where to place the buttons at to control swapping 
> between views. At certain times I don't want the buttons to be there unless 
> certain conditions are met. So that led me to the idea of placing the buttons 
> I want within the Views, this is different from the example which provides a 
> drop-down menu that's always visible as provided in the example. So I have a 
> refresh button (left side of the split view)that checks that the conditions 
> are right, if they are it loads the first view, I have this part working.
> 
> The part I am having trouble with is getting the buttons I make in each view 
> to call a method in the Window Controller.  I figured swapping in out views 
> would be a much better solution than doing a whole lot of setHidden: calls.  
> The Views that I am swapping in are subclasses of NSViewController. I have 
> tried adding a NSObject in Interface Builder and classing it to that of my 
> Window controller, this allows me to connect the button to the method, but 
> causes a init loop, when I remove the refresh button method call from 
> awakeFromNib that causes the init infinite loop to stop but now view swapping 
> does not happen, even though my logs say the method is being called.  I am 
> new to Cocoa Development so any guidance and suggestions are welcomed, it 
> seems like I am doing this the hard way...


The buttons that control the view swapping don't want to be in the views that 
are swapped. They ought to be external to them, and handled by a separate 
(master?/parent?) controller.

If they need to be conditionally hidden, then maybe an informal protocol 
implemented by each view sub-controller can return whether a given button 
should be hidden or shown, and the master controller can then ask the 
subcontroller what to show/hide that way.

It sounds like you have something like a master/detail interface - if so then 
searching the archives and docs for those terms should unearth plenty of 
discussion and approaches.

--Graham


_______________________________________________

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