On Jun 10, 2008, at 5:05 PM, Paul Archibald wrote:

Comrades:

I am working on a file-handling Cocoa app that (at this point) has a single window. We are adding a second window (really sort of a non- modal dialog) to do some extra processing of the target files. The interface for the new window is already built (with IB), but is not hooked up yet.

So, the way this started was as a AppController(ExtraCategory) thing, with the NIB file having a single controller object. I don't like that method, because there is a lot of data and code that would need to be replicated in the main AppController to handle the work that the ExtraCategory does. What I would like to do is put all the ExtraCategory stuff into its own class, but I am not sure how. My inclination is toward making the ExtraCategory into a NSWindowResponder, but the documentation I have read so far makes it look like that is more intended for document-based apps, which this is not. Also, I don't quite see (looking at some example code) how an extra controller is instantiated by the main app controller.


Since there's no such thing as NSWindowResponder I assume what you meant was NSWindowController. And that's what you should use. There's no limitation of NSWindowController being only available or useful in document based apps.

You can instantiate it in the nib with IB or in code. I usually instantiate it in code and have it load the nib and be the file's owner.

@implementation MyWinController

- (id)initWithWhatever:(whatever*)whatever
{
        self = [super initWithWindowNibName:kMyWindowNibName];
    if (self) {
        // Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
        }
    return self;
}

// etc.


// instantiate it in your app controller something like this:

- (void)showMyWindow
{
        if (! mMyWinController)
        {
mMyWinController = [[MyWinController alloc] initWithWhatever:whatever];
        }
        
        [mMyWinController showWindow:self];
}



_______________________________________________

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 [EMAIL PROTECTED]

Reply via email to