iPhone SDK - first 5 minutes. 8
Off course I couldn’t resist, I had to give it a try. The sdk is a whopping 2GB download and 5.6 Gb install. It installs all the developers tools, java, gcc4.2, WebObjects, the kitchen sink. Upon successful installation the system needs to be restarted.
Start XCode and select ‘New Project…’ from the File menu. You can then select from 3 type of iPhone Applications
Let’s try the Cocoa Touch List and I name my test project TimeList.
This creates a standard XCode project:
I clicked “Build and Go”...the application is compiled and linked after 20 seconds got an emulate iPhone with the TimeList app visible:

Clicking on it we get a pre-populated list of timezones which behaves just like an iPhone:

Note the emulator application is called Aspen Simulator, it has a ‘Hardware’ menu that should allow to rotate the UI but that doesn’t seem to work. The emulator really feels like an iPhone, all the finger gestures can be done with the mouse and the UI behaves like an iPhone. Pretty cool.
Let’s look at the TimeListAppDelegate generated code:
//
// TimeListAppDelegate.m
// TimeList
//
// Created by Daniel Wanja on 3/7/08.
// Copyright __MyCompanyName__ 2008. All rights reserved.
//
#import "TimeListAppDelegate.h"
@implementation TimeListAppDelegate
@synthesize window;
@synthesize tableView;
- init {
if (self = [super init]) {
// Your initialization code here
}
return self;
}
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// Create window
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Set up table view
tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame] style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
// Show the window with table view
[window addSubview:tableView];
[window makeKeyAndVisible];
[tableView reloadData];
}
- (void)dealloc {
[tableView release];
[window release];
[super dealloc];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[NSTimeZone knownTimeZoneNames] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath withAvailableCell:(UITableViewCell *)availableCell {
UISimpleTableViewCell *cell = nil;
if (availableCell != nil) {
cell = (UISimpleTableViewCell *)availableCell;
} else {
CGRect frame = CGRectMake(0, 0, 300, 44);
cell = [[[UISimpleTableViewCell alloc] initWithFrame:frame] autorelease];
}
cell.text = [[NSTimeZone knownTimeZoneNames] objectAtIndex:[indexPath row]];
return cell;
}
@endLooks like I have lots to read about before I can start changing that application. From what I can decipher once the application is initialized a UITableView is created and the delegate of the table view becomes the TimeListAppDelegate whish implements the numberOfRowsInSection and cellForRowAtIndexPath methods which uses the NSTimeZone knowTimeZonesNames as data source.
That was my first 5 minutes with the SDK. More to follow…now I have to go back to work :-( Next thing I will try out is the Interface Builder…stay tuned.
Enjoy! Daniel.
It would be awesome if you could build iPhone apps with MacRuby!
Please don’t forget that access to the iPhone SDK is covered by an NDA which prohibits publicly posting details about the SDK itself.
Well, I wouldn’t release anything If would have signed an NDA, but I don’t think there was any NDA when downloading the Free SDK. The name of the SDK may be missleading, it’s free and available for anyone to download who has an appleid, so I don’t believe am divulging any confidential information in the above blog entry. Please correct me if I am wrong. Furthermore there is nothing in the above blog entry that hasn’t been made publicly available during yesterdays keynote . I’ll make sure to go through all the fine print before releasing any further information. But the SDK really Rocks! Tons of example, awesome documentation. iPhone development looks to be really fun.
save the time… the interface builder is not included yet. it’s “coming soon”. i was looking for it, too ;-)
The download time and take up of memory space should be worth it! When this was announced I was just so excited. but I am still downloading now .
Well, a blank new application do not look so daunting. Try it. Easy to build, but yes I’m also working on how to do a GUI. Tough without an interface builder. Back to handcoding fun days!
Yeah, looks like you have lots to read about before :) All in all, quite interesting…
I have never even seen a Mac .. From the source code it is obvious it is not C nor C++.
1. Is it Objective-C? 2. Are there C or C++ APIs in the SDK?
Thanks, Roy