Hello,

When you load a NIB file, you can pass an file's owner parameter. The
file's owner can be configured when you edit the NIB file (by default
it is the NSApplication shared instance).

So, you can try the following:
- Edit the Form2 NIB and define the Form2Controller class as the file's owner.
- In Form1Controller, create an instance of Form2Controller.
- Load the Form2 NIB by passing the instance of Form2Controller as the
file's owner.
-> You have your two controllers that can talk to each other.

This is not the only solution, but this is the spirit. I suggest you
to read 
http://developer.apple.com/documentation/DeveloperTools/Conceptual/IB_UserGuide/BuildingaNibFile/chapter_4_section_1.html#//apple_ref/doc/uid/TP40005344-CH11-SW1
and especially the chapter "Nib File Design Guidelines". It will help
you to understand what to put in the NIB files and how to coordinate
the loading.

Regards, Laurent Etiemble.

2008/11/12 Miguel De Buf <[EMAIL PROTECTED]>:
> Hi Laurent,
>
> I get that, and it works really nice, but I cannot pass data from one
> controller to another :-(
>
> In Form1Controller, I execute loadnib('Form2').  And I need to pass some
> data to Form2Controller.
> Since loadnib('Form2') does not return me a pointer to the controller or so,
> I cannot pass data to that controller.
>
> I am almost sure, I am missing something here...
>
> Thanks,
> Miguel
>
>
> Laurent Etiemble wrote:
>
> Hello,
>
> In Cocoa, you should follow Model/View/Controller pattern.
>
> So you should consider the FormXController as the entry points for
> manipulating the windows. This means that you should pass data from a
> controller to another (Don't put your logic in NSWindow subclasses).
>
> Regards, Laurent Etiemble.
>
> 2008/11/12 Miguel De Buf <[EMAIL PROTECTED]>:
>
>
> Hi all,
>
> I want to transfer data from one window to another, and cannot find a decent
> way to do that (if possible at all).  Note that I am a cocoa beginner coming
> from winforms.
>
> The use case is :
>
> 1. I open a form (loadnib) with controller Form1Controller.
> 2. From within the controller, I open a second form (loadnib) with
> controller Form2Controller.
> 3. I want to pass custom data to Form2 during this creation/form-loading.
>
> How can I accomplish that ?  In winforms, I would just do (from within
> Form1) :
>
> ...
> Form2 f = new Form2();
> f.customData = "mycustomdata";
> ...
>
> Seems so simple...
>
> Thanks in advance,
> Miguel
>
>
> --
>
> Miguel De Buf
> Chief Technology Officer
> Aventiv NV, creators of NomaDesk(R)
> Tel. +32 9 233 68 86 (Belgium)
> Fax +32 9 240 10 39 (Belgium)
> [EMAIL PROTECTED]
>
> Confidentiality Notice:
> This message, together with any attachments, is intended only for the use of
> the individual or entity to which it is addressed. It may contain
> information that is confidential and prohibited from disclosure. If you are
> not the intended recipient, you are hereby notified that any dissemination
> or copying of this message or any attachment is strictly prohibited. If you
> have received this item in error, please notify the original sender and
> destroy this item, along with any attachments.
>
>
>
> --
>
> Miguel De Buf
> Chief Technology Officer
> Aventiv NV, creators of NomaDesk(R)
> Tel. +32 9 233 68 86 (Belgium)
> Fax +32 9 240 10 39 (Belgium)
> [EMAIL PROTECTED]
>
> Confidentiality Notice:
> This message, together with any attachments, is intended only for the use of
> the individual or entity to which it is addressed. It may contain
> information that is confidential and prohibited from disclosure. If you are
> not the intended recipient, you are hereby notified that any dissemination
> or copying of this message or any attachment is strictly prohibited. If you
> have received this item in error, please notify the original sender and
> destroy this item, along with any attachments.
>

Reply via email to