Re: Interface Builder : moving a controller to File's Owner
Re: Interface Builder : moving a controller to File's Owner
- Subject: Re: Interface Builder : moving a controller to File's Owner
- From: "email@hidden" <email@hidden>
- Date: Fri, 5 Mar 2010 10:48:31 +0000
On 5 Mar 2010, at 08:29, David Geldreich wrote:
> Hello Kyle and all cocoa-devers,
>
> Le 5 mars 10 à 00:21, Kyle Sluder a écrit :
>
>> On Thu, Mar 4, 2010 at 1:45 PM, David Geldreich <email@hidden> wrote:
>>> I am refactoring one big NIB file into smaller pieces. I copy/paste a
>>> WindowController object and a Window object in a new "empty" NIB.
>>
>> Window controllers don't belong in nibs. You create them in code and
>> ask them to load a nib, at which point they fill in as File's Owner
>> (unless you use the variant in which you provide a different File's
>> Owner, but you almost never actually want to use that).
>
> That's my problem, I want to create the WindowController in my code and then attach the NIB to it.
>
> When I create my NIB file from scratch, that's what I do. But here, I am refactoring on big NIB file into smaller files to ease the maintenance.
>
> The WindowController and Window (with tons of connections) already exist in a very big NIB. I want to extract the WindowController/Window from this NIB file, keep all the connections and put them in a new NIB file.
>
> When I copy/paste WindowController/Window from my big NIB to the new NIB, I do not know how to "move" all the connections to/from WindowController to the File's Owner "object" ?
>
> For example, if you use the refactoring (File | Decompose Interface) of InterfaceBuilder, you end up having your WindowsController/Window separated from File's Owner.
>
> Regards.
>
> David
Including the window controller in the nib is a non standard approach.
Your situation is comprehensible though if you have only done it this way.
So:
1. Decompose your monster nib as required.
2. In IB select Files's Owner and display the Identity Inspector.
3. Set the class to that of your custom window controller.
4. Now hook up your nib targets and actions to the File's Owner.
I normally then define an -init method on my window subclass.
When the window controller is instantiated it loads the nib with self as file's owner.
- (id)init
{
self = [super initWithWindowNibName:@"MyWindowNib"];
return self;
}
Regards
Jonathan Mitchell
Developer
http://www.mugginsoft.com
>
>
>
>
> _______________________________________________
>
> 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
_______________________________________________
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