Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6941607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:54:27+00:00 2026-05-27T12:54:27+00:00

I am going through several example code banks and tutorials and just completely stumbling,

  • 0

I am going through several example code banks and tutorials and just completely stumbling, a lot of it is due to the fact that these tutorials are written for Xcode < 4.2 and ARC changes a few things.

I am attempting to build an interface with an MVC design pattern. I am using the basic template provided for the Application Delegate. I have added a class called MainWindowController which inherits from NSWindowController. In the Interface Builder, firstly I removed the Window object in the MainMenu nib file (because I want it in a separate file). I create a new Interface called MainWindow(.xib) I change the file owner to MainWindowController I add the Delegate to the Object List. Now at this point something is not clicking.

I do not fully grasp how or what I need to implement in order for the Delegate to essentially load and launch the Window Controller. First I tried linking the outlet for “delegate” in the Window to the actual application delegate (called AppDelegate) and then linking the Window Outlet in the Delegate class to the Window in Interface Builder.

I would like an answer to this but I would be far more happy with the correct documentation describing this process. I’m sure there is something on MacDev but I’m having trouble finding it.

Here’s what I’m working with:

  @class MainWindow;

  @interface AppDelegate : NSObject <NSApplicationDelegate>


  @property (strong) MainWindow *mainWindowController;
  @property (assign) IBOutlet NSWindow *window;

  @property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;
  @property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
  @property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;

  - (IBAction)saveAction:(id)sender;

  @end

…

  @implementation AppDelegate

  @synthesize window;
  @synthesize mainWindowController;
  @synthesize persistentStoreCoordinator = __persistentStoreCoordinator;
  @synthesize managedObjectModel = __managedObjectModel;
  @synthesize managedObjectContext = __managedObjectContext;

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

     // ... the rest handles the ManagedObject Models...

Solution to date:

@synthesize mainWindowController = _mainWindowController; // IBOutlet is linked in IB
//...
- (void) applicationDidFinishLaunching: (NSNotification *) aNotification
{
    //... initialization of event handling etc...
    if ( !_mainWindowController ) _mainWindowController = [[ MainWindowController alloc] initWithWindowNibName:@"MainWindow"];
    [_mainWindowController showWindow: self];
    // ...

The application delegate can manage an NSWindow in the main nib file or it can delegate that task to a controller (NSWindowController) which is typical of document based applications or MVC design patterns. The default nib file specified by the Basic-info.plist defines which nib file is loaded. Typically the default nib should be the main menu, which loads the delegate as well. The delegate should then by means of applicationDidFinishLoading: or awakeFromNib: perform initialization of the controllers and continue appropriate delegation in accordance with the delegation and mvc design patterns.

The main problem I was having was launching the window, which is done by showWindow: . The exacerbation of this problem stemmed from source code from a very old Mac OS X project that used deprecated functions and methods to accomplish delegation and led me down the wrong path. Thanks for the answer, it ultimately had me look in the right place for the right questions and I found the right answer.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:54:28+00:00Added an answer on May 27, 2026 at 12:54 pm

    Your problem is that in that second xib, “MainWindow”, a new AppDelegate object is being created that has absolutely nothing to do with the AppDelegate object in the “MainMenu” xib. The objects in each xib are real objects that get serialized and then loaded at runtime.

    This specific issue will be addressed in the Resource Management Guide, “Nib Loading”. I can also suggest “Core Application Design”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just going through the sample Scala code on Scala website, but encountered an annoying
I'm going through my colleagues code, he has written several Page.IsValid checks but I
I am new to symfony, after going through several online tutorials and blogs, i
I was going through some videos. I found that Windows Azure will group the
I was just going through programming structure studies; In particular I was studying concurrent
I'm going through Intermediate Perl and it's pretty cool. I just finished the section
Recently I have been going through a project in an attempt to sanitize several
after going through some basic tutorials on the app engine and the webapp framework,
I have several Youtube videos that are added through a CMS by a client.
Going through some of my older Delphi projects and upgrading them to D2009, as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.