Re: Custom sheet question - which variable?
Re: Custom sheet question - which variable?
- Subject: Re: Custom sheet question - which variable?
- From: Jenny M <email@hidden>
- Date: Mon, 11 Jan 2010 22:42:02 -0800
Thanks guys, I think I am understanding this more now. A few more
questions...
You can do whichever you like. I tend to wander objects up and down my
> various controller and delegate chains as I write code because where I think
> I want it, I sometimes don't want it. Ask yourself this, what is this sheet
> most closely tied to? Is it something which is going to be used in the
> delegate on some kind of delegate callback? If so, you probably want the
> delegate to own it. Or is it something the WindowController really wants to
> 'own'? If that's the case then let it own it.
>
It's going to be possible to call the window from a menu selection, and not
as a sheet under the main window, so at least for now, I'd like to keep the
xib and window controller separated from the main AppDelegate. AppDelegate
is going to control the main flow, but each NSWindowController is going to
handle their own objects.
> If (in the code you posted) you're at that point in your AppDelegate then
> 'self', the thing you pass as owner, is the wrong type for the way you say
> you have your XIB configured. You need to make sure that the 'owner' is an
> object of the class you've told the XIB that File's Owner is; it can be what
> you like, but you have to be consistent. If you want it to be in your
> NSWindowController subclass, then for 'owner' you need to pass that window
> controller subclass object and the window you require will end up bound to
> some properly (you define) of that, then you pass [ yourWindowController
> thePropertyYouChose ] as the window to your sheet method.
>
>
So I do want the NSWindowController subclass as File's Owner, which means I
need a reference to the NSWindowController in the AppDelegate class. So, in
the AppDelegate.h file, I have MyNSWindowControllerSubclass
*objectWindowController, and in AppDelegate.m, I initialize it, right?
*objectWindowController = [[MyNSWindowControllerSubclass alloc]
initWithWindowNibName:@"MyObject"];
In what AppDelegate method do I need to run that code?
applicationDidFinishLaunching? init?
And don't forget, in your XIB .. you need to make the connection to the
> property in File's Owner. Oh yes it's easily said but so easily overlooked
> and you'll be asking why your sheet doesn't come up after you loaded the NIB
> and it will be because the outlet is nil because you didn't actually hook it
> up graphically in IB.
>
Haha, been there, done that! I was clicking the Close button I'd hooked up
and wondering why the function was calling but the window wasn't closing. ;)
_______________________________________________
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