MainWindow missed on Xcode 4.2

Hello, as you have noticed there is no MainWindow in the empty templates of Xcode 4.2 as in the previous versions of Xcode. Thus, we can go through this new approach or try to do it as was before.

Please note that these instructions are just to remind me how to do it. I will elaborate the instructions in a better way other day; when I have more time to do it. Meanwhile, you can visit the site of Jeroen Trappers. In this post he explains in detail how to recreate the MainWindow.

Needless to say, here you have the principal instructions in order to have your own MainWindow:

  1. Create a new project
  2. Add a new empty interface file, to be simplistic use the name MainWindow, but you can use the name you want.
  3. Click on the new created file. This take to the new Interface Builder.
  4. Change the class of File’s Owner to UIApplication.
  5. From the objects library drag the general Object onto the Objects section in the left side of the Xcode Interface Builder.
  6. Change the class of such Object to AppDelegate.
  7. From the objects library drag the Window object onto the Objects section.
  8. To hook everything up; first we add the code below in the AppDelegate interface file (AppDelegate.h)
    @property (strong, nonatomic) IBOutlet UIWindow *window;
  9.  Then we click on the MainWindow.xib and after that on the File’s Owner. From the bindings sections of the File’s Owner (fifth tab on the right side) we perform a control-drag from the outlet delegate to the AppDelegate Object in the Objects section
  10. Now click on the AppDelegate object in the objects sections. From the bindings section (fifth tab at the right side) we perform a control-drag from the outlet window to the window object in the objects section.
  11. After hook everything we have to indicate what our main interface is. To do that, we navigate to the project and in the summary tab we select MainWindow as our Main Interface.
  12. To finalize we have to comment the piece of code that creates the window in the AppDelegate.m. The method that we have to comment is:
    – (BOOL) application:didFinishLaunchingWithOptions:
  13. That’s it. Now you can run your app and the window.xib will be launched. You can add a button or label just to be sure that the launched window is the one that we have created.

Thank you for reading this. Tot Straks!

Advertisements

One Reply to “MainWindow missed on Xcode 4.2”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s