About | ACP | Buy | Industry Watch | Learning Curve | News | Products | Search | Substack
Home » Learning Curve » Developers Workshop

Hello iPhone

Put it all together, stir into a project, serve immediately. Finish off with an apple.


#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#import <UIKit/UIPushButton.h>
#import <UIKit/UITableCell.h>
#import <UIKit/UIImageAndTextTableCell.h>

@interface HelloApplication : UIApplication {
    UIImageAndTextTableCell *pbCell;
    UITableCell *buttonCell;


#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/CDStructures.h>
#import <UIKit/UIPushButton.h>
#import <UIKit/UIThreePartButton.h>
#import <UIKit/UINavigationBar.h>
#import <UIKit/UIWindow.h>
#import <UIKit/UIView-Hierarchy.h>
#import <UIKit/UIHardware.h>
#import <UIKit/UITable.h>
#import <UIKit/UITableCell.h>
#import <UIKit/UITableColumn.h>
#import "HelloApplication.h"

@implementation HelloApplication
-(int)numberOfRowsInTable:(UITable *)table {
    return 2;
-(UITableCell *)table:(UITable *)table cellForRow:(int)row column:(int)col {
    return (row)? buttonCell: pbCell;
-(UITableCell *)table:(UITable *)table cellForRow:(int)row column:(int)col reusing:(BOOL)reusing {
    return pbCell;
-(void)applicationDidFinishLaunching:(id)unused {
    UIWindow *window;

    window = [[UIWindow alloc] initWithContentRect:[UIHardware fullScreenApplicationContentRect]];

    pbCell = [[UIImageAndTextTableCell alloc] init];
    [pbCell setTitle:@"Hello world!"];

    UIPushButton *button = [[UIThreePartButton alloc] initWithTitle:@"Touch Me"];
    buttonCell = [[UITableCell alloc] init];
    [buttonCell addSubview:button];
    [button sizeToFit];

    UITable *table = [[UITable alloc] initWithFrame:CGRectMake(0f, 48f, 320f, 432f)];
    UITableColumn *col = [[UITableColumn alloc] initWithTitle:@"HelloApp" identifier:@"hello" width:320f];

    [window orderFront:self];
    [window makeKey:self];
    [window _setHidden:NO];

    [table addTableColumn:col];
    [table setDataSource:self];
    [table setDelegate:self];
    [table reloadData];

    UINavigationBar *nav = [[UINavigationBar alloc] initWithFrame:CGRectMake(0f, 0f, 320f, 48f)];
    [nav showButtonsWithLeftTitle:@"Foo" rightTitle:@"Bar" leftBack:YES];
    [nav setBarStyle:0];

    struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
    rect.origin.x = rect.origin.y = 0f;
    UIView *mainView;
    mainView = [[UIView alloc] initWithFrame:rect];
    [mainView addSubview:nav];
    [mainView addSubview:table];

    [window setContentView:mainView];


LDFLAGS=-lobjc -framework CoreFoundation -framework Foundation -framework UIKit -framework LayerKit

all:    Hello

Hello:  hello.o HelloApplication.o
        $(LD) $(LDFLAGS) -o $@ $^

%.o:    %.m
                $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

                rm -f *.o Hello


int main(int argc, char *argv[]) {
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    return UIApplicationMain(argc, argv, [HelloApplication class]);


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
<plist version="1.0">

See Also
Alpine Dottie
Effective UID: 0
iPhone Ramdisk
iPhone and Security
iPhone and the Media
iPhone and Full Disclosure
iPhone Hack to be Patched
iPhone OS X System Architecture
iPhone Bootloader: Hackint0sh Progress Report

Thanks to Devon at Pixel Groovy for the excellent artwork.

About | ACP | Buy | Industry Watch | Learning Curve | News | Products | Search | Substack
Copyright © Rixstep. All rights reserved.