Reputation: 269
I have a Login.xib and a Main.xib and if you logged in once I store the token into a file. If this file with the token exists , I want to show the Main window instead of Login, because I already know which user it is.
Where and how i could decide which Window i should display?
Upvotes: 2
Views: 59
Reputation: 13177
I would check for the existence of this file in your application delegates applicationDidFinishLaunching: method.
If the file exists display the main window otherwise show the login window.
Edit
In response to your comment you will need to look into the use of the NSWindowController class. Basically you will have an NSWindowController object for every window you want to control.
You will also need to change a few things in your application to change the default behaviour of loading the main window which will differ depending on whether or not you are making a document based application.
If your application is not a document based, your application 'knows' to load the main.xib because this is set in your application's info.plist file. Basically, when your application starts up it looks in the info.plist file to find out which nib requires loading and loads it. Typically the main nib contains a menu and a window. Simply delete the window and re-create it in a separate nib to stop the window loading up by default.
If your application is document based then things are a little different. You will have an NSDocument subclass which should have a method called windowNibName which returns the name of the nib file to be loaded. Remove this method and instead override makeWindowControllers to return your NSWindowController objects. There is a bit more to it than this but this should get you started and the rest is beyond the scope of your original question.
Upvotes: 2