I don't like visual development tools that are supposed to write a program for me. Even if it is
Xcode and I can use
Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small and trivial, when few standard GUI controls could be arranged easily on the basic view and, then, connected to my code objects in
At some point, though, the programs became a little bigger than a simple tutorial program, a little more complicated than one full-screen view with three labels and one button. Now I have to worry about having enough memory for my application and I so I now desire to eliminate everything related to
This article shows how to accomplish this using an easy and fast trick.
iPhone Application Project.
Let's make a simple iPhone project:
1. Create new iPhone window-based application project.
In Xcode, in menu
"New Project...". In the project wizard sidebar select
Application in the
iPhone OS section. Select
Windows-based Application in the right panel and click on
Choose button in the bottom-right corner. In the Save panel give a name for the project. For example, "Simple", and click
These two screenshots illustrate this step:
2. Delete Classes folder and xib-file.
In Xcode project window, find
Classes folder and delete it - select
"Classes" item, click on the right mouse button and in the popup menu select
"Delete". In the alert window click on
"Also move to trash" button.
When the project (the most top item) is selected in the Xcode sidebar, on the right panel you see all project files. Find
MainWindow.xib file and delete it too.
Here are the screenshots:
3. Modify *-info.plist file.
Simple-info.plist file to select it. The bottom panel shows the file content. There is a line about the MainWindow.xib file:
"Main nib-file base name". The last one in my file. Delete it.
4. Modify main.m file.
Source code of this program will be in
main.m file. Open this file for editing and add new application delegate class. Use the class name in the main function. Basically, it means to replace the original content of main.m file with the following code:
Be sure that the active configuration is
Simulator is selected as the target device. Popup button in the Xcode Toolbar allows changing the active configuration and the target device.
"Build & Run" button to launch the program.
This program does not have an icon, so iPhone Simulator shows a white rectangle instead. Icon for the iPhone application is a PNG-image. In the simplest case it has size 57x57 pixels and the name is
icon.png. Drag any image that fits to this requirement to the resource folder in the Xcode project. Do not forget to check
"Copy item to the destination group folder":
I attached my icon.png file as an example. I attached also
Default.png - this is another special image that is used by iOS without any coding required from the developer. Add this image to the project resources. Build and launch the application. When it is loaded, this Default.png works as a splash screen.
Everything related to Interface Builder was removed from the iPhone project. The source code is concentrated in main.m file. It is very convenient when I'm learning, when I need to check or to test something quickly - a language feature, new API or an idea.
For example, the code below placed in the -applicationDidFinishLaunc
hing method will show how to work the Cocoa date/timer formatter: