iPhone SDK - first 5 minutes. 8

Posted by Daniel Wanja Fri, 07 Mar 2008 16:16:03 GMT

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
20080307_1_iphone_projects.gif

Let’s try the Cocoa Touch List and I name my test project TimeList.

This creates a standard XCode project:
20080307_2_XCodeProject.jpg

I clicked “Build and Go”...the application is compiled and linked after 20 seconds got an emulate iPhone with the TimeList app visible:

20080307_3_iPhoneHome.jpg

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

20080307_4_TimeList.jpg

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;
}

@end

Looks 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.

Comments

Leave a response

  1. Mike Fri, 07 Mar 2008 18:21:52 GMT

    It would be awesome if you could build iPhone apps with MacRuby!

  2. Concerned Netizen Fri, 07 Mar 2008 19:08:16 GMT

    Please don’t forget that access to the iPhone SDK is covered by an NDA which prohibits publicly posting details about the SDK itself.

  3. Daniel Wanja Fri, 07 Mar 2008 19:29:23 GMT

    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.

  4. fake Fri, 07 Mar 2008 19:40:12 GMT

    save the time… the interface builder is not included yet. it’s “coming soon”. i was looking for it, too ;-)

  5. JJ Sat, 08 Mar 2008 01:01:23 GMT

    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 .

  6. KANG Ghee Keong Mon, 17 Mar 2008 10:41:03 GMT

    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!

  7. Derek Fisher Mon, 17 Mar 2008 16:30:34 GMT

    Yeah, looks like you have lots to read about before :) All in all, quite interesting…

  8. Roy Thu, 10 Apr 2008 10:20:13 GMT

    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

Comments