Hi David,

You'd probably be better off making Files Owner a subclass of 
NSWindowController, as it is controlling a window. (That it's a panel is not a 
reason not to). While in this case the advantage is likely to me minimal, it's 
probably good practice to get into using the right object for the job.

>> NSApp runModalForWindow:dlg->m_hoops]

You also don't want to be doing this sort of thing. You're exposing an internal 
ivar of your object for the use of another object, which is bad practice. 
Instead, declare a method on your window controller class such as -runModal, in 
which you run the window modally. (A good way to flag design errors of this 
kind and force yourself to be disciplined about it, is to by habit, declare all 
ivars as @private initially).

- (NSInteger) runModal
{
    return [NSApp runModalForWindow:[self window]];
}

By doing it like this the client of this code uses your window controller 
object as it is meant to - without caring or having any knowledge of its 
internal implementation details. That gives you the ability to change those 
details (extremely substantially if you wanted) and as long as you didn't break 
your contract with your client (your object's API) then it will still work and 
no other code needs to change.



--Graham




On 03/03/2010, at 9:43 AM, David Blanton wrote:

> I inadvertently set a view in the nib to the class I was instancing.
> 
> Sorry for the noise.
> 
> -db
> 
> 
> 
> On Mar 2, 2010, at 2:53 PM, David Blanton wrote:
> 
>> I have a nib file named Hoops.
>> 
>> In this nib is an NSPanel.
>> 
>> Outlets and Actions are defined in Files Owner and connected to the Panel.
>> 
>> In code I create an object that has the corresponding Outlets / Actions as 
>> File's Owner.
>> 
>> I then loadNibNamed:owner with owner as the object just created.
> 

_______________________________________________

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