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 8769519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:21:55+00:00 2026-06-13T17:21:55+00:00

I am setting my first steps in OSX development and I’ve run into some

  • 0

I am setting my first steps in OSX development and I’ve run into some problems. I have quite some experience with iOS development but the window system for OSX programs is something else.

I am making a client for a social network like twitter and need 2 seperate window controller for first starting the app, one if you are logged in to show your timeline and one for logging in, if you are not yet logged in. In the info.plist you need to give it a main.xib. For this I made an empty xib which I hide, the second the app starts. This is not really a good solutions IMO, what is a better solution for this? I want to keep the windows seperate from the appdelegate because that way I can keep my code seperated.

This gives me a problem, when I open my ‘second’ window to login it shows up but isn’t active. I have tried all the things like, orderFront:, activateIgnoringOtherApps:, makeKeyAndOrderFront: & more. But this all doesn’t work..

So: First off, is there a better way to handle the main.xib that is needed in the info.plist and if not, is there a way around the focus problem?
I’m working om osx 10.7

  • 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-06-13T17:21:56+00:00Added an answer on June 13, 2026 at 5:21 pm

    For more than one-offs, you really ought to separate your app delegate from your window controllers. Go ahead and create a new Cocoa application from the template. In MainMenu.xib, delete the window. In AppDelegate.h delete the IBOutlet to the NSWindow. Create a couple new subclasses of NSWindowController complete with XIBs–perhaps LoginWindowController and TimelineWindowController.

    For “final” NSWindowController subclasses (i.e. those which won’t be subclassed), the best practice for designated initializers is

    //for our example class LoginWindowController
    - (id)init
    {
        self = [super initWithWindowNibName:@"LoginWindowController"];
        if (self) {
            //....
        }
        return self;
    }
    

    Now in your app delegate, you should have @properties for the two different window controller instances:

    //Within AppDelegate.m
    
    #import "AppDelegate.h"
    #import "LoginWindowController.h"
    #import "TimelineWindowController.h"
    
    @interface AppDelegate ()
    @property (nonatomic) LoginWindowController *loginWindowController;
    @property (nonatomic) TimelineWindowController *timelineWindowController;
    //For the sake of this demo, add a property for the loggedIn state:
    @property (nonatomic) BOOL loggedIn;
    @end
    

    You ought to have some sort of method in your app delegate that presents the correct window controller. Let’s call it -updateWindowVisibility:

    - (void)updateWindowVisibility
    {
        BOOL isLoggedIn = self.loggedIn;
    
        BOOL loginWindowVisible = self.loginWindowController.window.isVisible;
        BOOL showLoginWindow = !isLoggedIn;
    
        BOOL timelineWindowVisible = self.timelineWindowController.window.isVisible;
        BOOL showTimelineWindow = isLoggedIn;
    
        if (!loginWindowVisible && showLoginWindow) {
            if (!self.loginWindowController) self.loginWindowController = [[LoginWindowController alloc] init];
            [self.loginWindowController showWindow:nil];
        } else if (loginWindowVisible && !showLoginWindow) {
            [self.loginWindowController close];
            self.loginWindowController = nil;
        }
    
        if (!timelineWindowVisible && showTimelineWindow) {
            if (!self.timelineWindowController) self.timelineWindowController = [[TimelineWindowController alloc] init];
            [self.timelineWindowController showWindow:nil];
        } else if (timelineWindowVisible && !showTimelineWindow) {
            [self.timelineWindowController close];
            self.timelineWindowController = nil;
        }
    }
    

    This method as implemented above does a tiny bit more work than is necessary given the present setup, but should be easier to modify when you need to show/hide other windows. All that’s left to do at this point is to call -updateWindowVisibility from -applicationDidFinishLaunching:.

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
        self.isLoggedIn = NO;
        [self updateWindowVisibility];
    }
    

    I’ve posted an example app to github which demonstrates this approach.

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

Sidebar

Related Questions

I'm setting up my first development Linux box - a netbook actually. I'm quite
I'm new to web development but have plenty of Scala experience and am trying
This is the first time that I have attempted to add some localization into
Following the steps in this tutorial , the first item of Setting up with
So this is my first time using cookies and i'm having some trouble setting
A random class definition: class ABC: x = 6 Setting some values, first for
Still making my first steps in Ruby (while dealing with some written code). I
I'm running Mac OSX 10.6.4 and setting up rails for the first time. I've
I'm setting up my first symfony project, and am having trouble with the schema.
It is my first time setting up databases in MySQL and using them so

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.