iPhone Developer Tips Stats: Past 30 days - Pageviews: 88,766 Visitors: 61,679 Thank you everyone! Let's shoot for 100,000 by May. Pass it on...
|
When I start to learn a new development platform I prefer, at least in the beginning, not to develop behind a RAD tool like InterfaceBuilder. I like to understand how things work before I look to a tool to do the work for me. Doing things “by hand” (at least initially) often gives me a better understanding of the tools and helps me to deal with issues as they inevitably come up.
Here is a simple set of steps you can take to prepare a new project that doesn’t “hide” anything behind InterfaceBuilder.
Step 1. Remove the value in “info.plist” called “Main nib file base name”
Step 2. In the main.m file, change the line
int retVal = UIApplicationMain(argc, argv, nil, nil);
to …
int retVal = UIApplicationMain(argc, argv, nil, @"MyAppDelegate");
Where @"MyAppDelegate" is the name of your application delegate class.
Step 3. In the App Delegate class create a window and setup your view:
1
2
3
4
5
6
7
8
9
10
11
12
13
| - (void)applicationDidFinishLaunching:(UIApplication *)application {
// create and initialize the window (normally IB does this for you)
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Start to create the initial controller and view (this is typically where your code starts)
navigationController = [[RootViewController alloc] init];
// Configure and show the window (e.g. add you view to the window
[window addSubview:[navigationController view]];
// Now show the window
[window makeKeyAndVisible];
} |
Step 4. (Optional) Remove the IBOutlet from the @property lines in the Application Delegate file because these are only ever used by the InterfaceBuilder.
Step 5. (Optional) Go ahead and delete any of the *.xib files that may have been created by the new project wizard.
Comments
One Response to “Real Men Don’t Use Interface Builder”
Leave Comment
Hi, this is a great post, I have a question, if you build from scratch rather than using Interface Builder, will you still be notified for events like memory low warning, and something viewDidLoad?
Thanks!