• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to open two nibs at app launch ? Beginners question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to open two nibs at app launch ? Beginners question


  • Subject: Re: How to open two nibs at app launch ? Beginners question
  • From: Mario Kušnjer <email@hidden>
  • Date: Mon, 13 Apr 2009 12:27:26 +0200


On 2009.04.13, at 11:15, Quincey Morris wrote:

Not exactly. Make your application delegate (let's say its class is MyAppDelegate) separate from your window controller. So, the steps are:


-- write a MyAppDelegate class (subclass of NSObject)

-- in IB, drag an object into MainMenu.xib, and set its class to MyAppDelegate (that causes an instance to be created automatically when your app starts up)

-- in IB, connect the 'delegate' outlet of the (predefined) Application object in MainMenu.xib to the MyAppDelegate object (that causes your MyAppDelegate object to actually *be* the application's delegate)

-- in your MyAppDelegate class, add an instance variable mainWindowController, of class MainWindowController

-- in your MyAppDelegate class, write an applicationDidFinishLaunching: method something like this:

- (void) applicationDidFinishLaunching: (NSNotification *) aNotification {
mainWindowController = [[MainWindowController alloc] init];
[mainWindowController showWindow: nil];
}


-- your MainWindowController's init method should look something like this:

	- (id) init {
		self = [super initWithWindowNibName: @"MainWindow"];
		if (!self) ...
		...
		return self;
	}

-- in IB, set the class of File's Owner in MainWindow.xib to MainWindowController

I may have left out something, but that's the basic idea.

It's working ! Thank you!

Tell me please should and in what cases would I keep MyAppDelegate separate from MainWindowController and in what not, because I kinda made it work all from one place:

#import <Cocoa/Cocoa.h>


@interface MainWindowController : NSObject { NSWindowController *mainWindowController; }

@end
________________________________________________________________________________

#import "MainWindowController.h"


@implementation MainWindowController

- (void) applicationDidFinishLaunching:(NSNotification *) aNotification
{
mainWindowController = [[NSWindowController alloc] initWithWindowNibName:@"MainWindow"];
[mainWindowController showWindow:nil];
}


@end

And about delegates, so if I want to do something else now I have to create another object in MainMenu.nib and make it a delegate of proxy object Application again ?
There can be multiple delegations for one Application object ?
Or should I make one object that will be a delegate but will hold the code for all other stuff ?
Could you explain this to me a little bit more ?


Thanks !

Mario

_______________________________________________

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


  • Follow-Ups:
    • CGContextClipToMask
      • From: aashram <email@hidden>
    • Re: How to open two nibs at app launch ? Beginners question
      • From: Michael Ash <email@hidden>
References: 
 >How to open two nibs at app launch ? Beginners question (From: Mario Kušnjer <email@hidden>)
 >Re: How to open two nibs at app launch ? Beginners question (From: Quincey Morris <email@hidden>)
 >Re: How to open two nibs at app launch ? Beginners question (From: Mario Kušnjer <email@hidden>)
 >Re: How to open two nibs at app launch ? Beginners question (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: stopping an application
  • Next by Date: Re: static vs non-static. Recommendation needed.
  • Previous by thread: Re: How to open two nibs at app launch ? Beginners question
  • Next by thread: Re: How to open two nibs at app launch ? Beginners question
  • Index(es):
    • Date
    • Thread