Re: re-making connections with a different controller

2009-06-10 Thread Quincey Morris

On Jun 10, 2009, at 07:40, Stephen Blinkhorn wrote:

Can I make connections programmatically?  That might be easier for  
now.


It's catch-22, I think. You have to find all the controls that need  
their target set, and identify which target to use for which control.  
Normally, the easiest way to do that would be to use IBOutlets, but  
you'd need hundreds of those, and then you'd have to drag a connection  
from each to the corresponding control. :)



___

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


Re: re-making connections with a different controller

2009-06-10 Thread Scott Andrew
One other thing to keep things simple.. Take all common functionality  
and put it into a base view controller class. Then subclass from there  
for any new controls, functionality, setup, etc.


Scott

On Jun 10, 2009, at 7:40 AM, Stephen Blinkhorn wrote:


On 9 Jun 2009, at 22:44, Quincey Morris wrote:


On Jun 9, 2009, at 19:50, Stephen Blinkhorn wrote:

If you must use a tab view, you could also approach it with a  
view xib and a view controller to define the common part of each  
tab. The view controller would act as an intermediary to pass the  
action methods on to the correct controller. (The details, and  
feasibility, of this approach might depend on exactly what class  
of controllers you're trying to use.)


That sounds interesting but will involve a near complete overhaul.


Are you sure?


Well, yes and no.  I'm writing the GUI for a real time audio  
program.  The back end of that is written in C++ which I've written  
too.  The Cocoa UI is getting quite complex now but is nearly  
finished so I'm a bit reluctant to tear it apart.  It is my first  
real Cocoa project though so I can't assume I've got it all right  
first time.



Moving the contents of the tabs to a different xib file (or is it  
xib files? are all the tabs identical in appearance?) is  
straightforward. Connecting the individual controls to the view  
controller (File's Owner) is straightforward. Writing intermediary  
action methods in your view controller subclass to pass the actions  
on the correct controller (held in an instance variable, or set as  
the representedObject) is straightforward.


All my tabs are identical.  The current purpose of my controller  
objects is to map the value from a control onto a nonlinear range.   
I display the nonlinear value in the UI for user feedback and then  
pass it to the C++ audio side.  There are a number of controls  
within in each tab(s) which require a custom mapping and differ from  
controller to controller based on some user selection.  Currently I  
deal with this by dynamically allocating/deallocating a kind of sub  
controller object of the required type at that time.



The only real work happens in (say) your window controller's  
awakeFromNib method. In that method, you would create as many view  
controllers as there are distinct tabs, passing the correct action  
controller object as a parameter, and letting the view controller  
instantiate its nib. Then, for each view controller, replace the  
appropriate tab subview with the view controller's view.


That doesn't require any design changes anywhere else in your  
application, AFAICT. It also has the advantage of making your life  
really easy if you ever have to add one more control to all of the  
tabs.


I know I will be adding and changing things over the next few months  
so I think it will be worthwhile putting the time in to implement  
something like this.  It isn't so much the tedium of manually  
connecting things together but the inevitability that a few  
connections will go astray at some point.  I did try something with  
bindings but it quickly got out of hand for me.


Can I make connections programmatically?  That might be easier for  
now.


Thanks,
Stephen


___

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/scottandrew%40roadrunner.com

This email sent to scottand...@roadrunner.com


___

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


Re: re-making connections with a different controller

2009-06-10 Thread Stephen Blinkhorn

On 9 Jun 2009, at 22:44, Quincey Morris wrote:


On Jun 9, 2009, at 19:50, Stephen Blinkhorn wrote:

If you must use a tab view, you could also approach it with a view  
xib and a view controller to define the common part of each tab.  
The view controller would act as an intermediary to pass the  
action methods on to the correct controller. (The details, and  
feasibility, of this approach might depend on exactly what class  
of controllers you're trying to use.)


That sounds interesting but will involve a near complete overhaul.


Are you sure?


Well, yes and no.  I'm writing the GUI for a real time audio program.   
The back end of that is written in C++ which I've written too.  The  
Cocoa UI is getting quite complex now but is nearly finished so I'm a  
bit reluctant to tear it apart.  It is my first real Cocoa project  
though so I can't assume I've got it all right first time.



Moving the contents of the tabs to a different xib file (or is it  
xib files? are all the tabs identical in appearance?) is  
straightforward. Connecting the individual controls to the view  
controller (File's Owner) is straightforward. Writing intermediary  
action methods in your view controller subclass to pass the actions  
on the correct controller (held in an instance variable, or set as  
the representedObject) is straightforward.


All my tabs are identical.  The current purpose of my controller  
objects is to map the value from a control onto a nonlinear range.  I  
display the nonlinear value in the UI for user feedback and then pass  
it to the C++ audio side.  There are a number of controls within in  
each tab(s) which require a custom mapping and differ from controller  
to controller based on some user selection.  Currently I deal with  
this by dynamically allocating/deallocating a kind of sub controller  
object of the required type at that time.



The only real work happens in (say) your window controller's  
awakeFromNib method. In that method, you would create as many view  
controllers as there are distinct tabs, passing the correct action  
controller object as a parameter, and letting the view controller  
instantiate its nib. Then, for each view controller, replace the  
appropriate tab subview with the view controller's view.


That doesn't require any design changes anywhere else in your  
application, AFAICT. It also has the advantage of making your life  
really easy if you ever have to add one more control to all of the  
tabs.


I know I will be adding and changing things over the next few months  
so I think it will be worthwhile putting the time in to implement  
something like this.  It isn't so much the tedium of manually  
connecting things together but the inevitability that a few  
connections will go astray at some point.  I did try something with  
bindings but it quickly got out of hand for me.


Can I make connections programmatically?  That might be easier for now.

Thanks,
Stephen


___

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


Re: re-making connections with a different controller

2009-06-09 Thread Quincey Morris

On Jun 9, 2009, at 19:50, Stephen Blinkhorn wrote:

If you must use a tab view, you could also approach it with a view  
xib and a view controller to define the common part of each tab.  
The view controller would act as an intermediary to pass the action  
methods on to the correct controller. (The details, and  
feasibility, of this approach might depend on exactly what class of  
controllers you're trying to use.)


That sounds interesting but will involve a near complete overhaul.


Are you sure? Moving the contents of the tabs to a different xib file  
(or is it xib files? are all the tabs identical in appearance?) is  
straightforward. Connecting the individual controls to the view  
controller (File's Owner) is straightforward. Writing intermediary  
action methods in your view controller subclass to pass the actions on  
the correct controller (held in an instance variable, or set as the  
representedObject) is straightforward.


The only real work happens in (say) your window controller's  
awakeFromNib method. In that method, you would create as many view  
controllers as there are distinct tabs, passing the correct action  
controller object as a parameter, and letting the view controller  
instantiate its nib. Then, for each view controller, replace the  
appropriate tab subview with the view controller's view.


That doesn't require any design changes anywhere else in your  
application, AFAICT. It also has the advantage of making your life  
really easy if you ever have to add one more control to all of the tabs.



___

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


Re: re-making connections with a different controller

2009-06-09 Thread Graham Cox


On 10/06/2009, at 9:15 AM, Stephen Blinkhorn wrote:

Perhaps this illustrates an underlying fundamental problem with the  
structure of my app but I don't want to know about that right  
now :)  Well, ok, maybe I do...



I think you recognise that this is indeed problematic... ;-)

If the controls are all the same, why not have one set of controls and  
one controller, and switch the connection from the controller to the  
data model instead? That sounds like a much more conventional and sane  
approach. Bindings or KVO can make that really easy to handle, with  
very little code required to "rewire" the controls to reflect the new  
data model object.


--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


Re: re-making connections with a different controller

2009-06-09 Thread Stephen Blinkhorn


On 9 Jun 2009, at 18:47, Quincey Morris wrote:

In the absence of further information, it seems that a tab view is  
wrong approach here. If all the so-called tabs are identical in user  
interface terms (that is, the only difference is the data they  
retrieve from your data model), you'd probably do better with a  
single set of the controls and a segmented control to choose which  
set of data values to use.


I simplified a little.  I have a grid of 16 NSTabViews each of which  
have at least 4 tabs.  I need to display all of this data  
simultaneously on one screen.


If you must use a tab view, you could also approach it with a view  
xib and a view controller to define the common part of each tab. The  
view controller would act as an intermediary to pass the action  
methods on to the correct controller. (The details, and feasibility,  
of this approach might depend on exactly what class of controllers  
you're trying to use.)


That sounds interesting but will involve a near complete overhaul.

Wagner: the text editor approach sounds ideal for now.

Thanks,
Stephen
___

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


Re: re-making connections with a different controller

2009-06-09 Thread Quincey Morris

On Jun 9, 2009, at 16:15, Stephen Blinkhorn wrote:

Imagine I have an NSTabView with 10 tabs that all contain the same  
collection of controls.  The only difference is that each control's  
action/outlet is connected to a different controller object (of the  
same class type).  Is it possible to select a whole tab of controls,  
copy them to the next tab and somehow change all the connections to  
and from Controller1 so that they now connect to Controller2,3,4,5,6  
etc without having to do 300 CTRL drags.


Perhaps this illustrates an underlying fundamental problem with the  
structure of my app but I don't want to know about that right  
now :)  Well, ok, maybe I do...


In the absence of further information, it seems that a tab view is  
wrong approach here. If all the so-called tabs are identical in user  
interface terms (that is, the only difference is the data they  
retrieve from your data model), you'd probably do better with a single  
set of the controls and a segmented control to choose which set of  
data values to use.


If you must use a tab view, you could also approach it with a view xib  
and a view controller to define the common part of each tab. The view  
controller would act as an intermediary to pass the action methods on  
to the correct controller. (The details, and feasibility, of this  
approach might depend on exactly what class of controllers you're  
trying to use.)



___

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


Re: re-making connections with a different controller

2009-06-09 Thread WT

Hi Stephen,

one approach that I have successfully employed several times when  
having to do a substantial amount of dreadful and error-prone  
mechanical work on xib files, of the kind you're talking about, is to  
use a text-editor and do a search and replace on the contents of the  
xib file. This works because xib files are xml files.


So, in your particular case, I'd set up ONE tab then copy all of its  
contents to all other 9 tabs, then save and close the xib file. Then  
I'd open the same xib file in a text editor (my favorite is BBEdit)  
and do a search/replace for the controller name. You can even do a  
grep search and replace so you won't have to do the same operation 9  
times, but only once.


If you haven't done this before, though, I strongly recommend that you  
keep a backup of your xib file prior to messing with it inside the  
text editor, because it's easy to muck things up and end up with a  
corrupted xib file.


Good luck.
Wagner

On Jun 10, 2009, at 1:15 AM, Stephen Blinkhorn wrote:


Hi all,

Imagine I have an NSTabView with 10 tabs that all contain the same  
collection of controls.  The only difference is that each control's  
action/outlet is connected to a different controller object (of the  
same class type).  Is it possible to select a whole tab of controls,  
copy them to the next tab and somehow change all the connections to  
and from Controller1 so that they now connect to Controller2,3,4,5,6  
etc without having to do 300 CTRL drags.


Perhaps this illustrates an underlying fundamental problem with the  
structure of my app but I don't want to know about that right  
now :)  Well, ok, maybe I do...


Thanks,
Stephen

___

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


re-making connections with a different controller

2009-06-09 Thread Stephen Blinkhorn

Hi all,

Imagine I have an NSTabView with 10 tabs that all contain the same  
collection of controls.  The only difference is that each control's  
action/outlet is connected to a different controller object (of the  
same class type).  Is it possible to select a whole tab of controls,  
copy them to the next tab and somehow change all the connections to  
and from Controller1 so that they now connect to Controller2,3,4,5,6  
etc without having to do 300 CTRL drags.


Perhaps this illustrates an underlying fundamental problem with the  
structure of my app but I don't want to know about that right now :)   
Well, ok, maybe I do...


Thanks,
Stephen



___

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