Skip to Content

Find your next home with Luxist's "Estate of the Day"
AOL Tech


Here's the code for the iPhone word processor

Makefile code:

CC=arm-apple-darwin-cc
LD=$(CC) LDFLAGS=-lobjc -framework CoreFoundation -framework Foundation -framework UIKit -framework LayerKit -framework CoreGraphics

all: SampleApp SampleApp: mainapp.o SampleApp.o
      $(LD) $(LDFLAGS) -v -o $@ $^

%.o: %.m

      $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

clean:

      rm -f *.o SampleApp


====
mainapp.m code:

#import <UIKit/UIKit.h>
#import "SampleApp.h"

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


====
SampleApp.h
code:

#import <CoreFoundation/CoreFoundation.h>
#import <Foundation/Foundation.h>
#import <UIKit/CDStructures.h>
#import <UIKit/UIWindow.h>
#import <UIKit/UIView-Hierarchy.h>
#import <UIKit/UIHardware.h>
#import <UIKit/UIKit.h>
#import <UIKit/UIApplication.h>
#import <UIKit/UITextView.h>
#import <UIKit/UIView.h>
#import <UIKit/UIKeyboard.h>

@interface SampleApp : UIApplication {
        UIView      *mainView;
        UITextView  *textView;
        UIKeyboard  *kb;
        NSString    *path;
        NSError     *error;
}

@end

====
SampleApp.m code:

#import "SampleApp.h"

@implementation SampleApp

- (void) applicationDidFinishLaunching: (id) unused
{
    UIWindow *window;
    struct CGRect rect = [UIHardware fullScreenApplicationContentRect];
    rect.origin.x = rect.origin.y = 0.0f;

    window = [[UIWindow alloc] initWithContentRect: rect];

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

    mainView = [[UIView alloc] initWithFrame: rect];

    textView = [[UITextView alloc]
        initWithFrame: CGRectMake(0.0f, 0.0f, 320.0f, 240.0f)];
    [textView setEditable:YES];
    [textView setTextSize:14];

    kb = [[UIKeyboard alloc]
        initWithFrame:CGRectMake(0.0f, 245.0f, 320.0f, 200.0f)];

    [window setContentView: mainView];
    [mainView addSubview:textView];
    [mainView addSubview:kb];

    path = @"/var/root/.s1text";

    [textView setText:
        [NSMutableString
            stringWithContentsOfFile:path
            encoding:NSMacOSRomanStringEncoding
            error:&error]];
}

- (void) applicationWillSuspend
{
   [[textView text]
        writeToFile: path
        atomically: NO
        encoding: NSMacOSRomanStringEncoding
        error: &error];
}

@end

====

Hacks in the wild

Building Apps


Fun with Ringtones


Unlocking

UI Hacking
Other

Tip of the Day

Holding the Command key (aka the Apple key) and pressing Tab will cycle through your open applications. It's easier to Cmd-Tab if you are Copy (Cmd-C) and Pasting (Cmd-V) to and from various applications.


Follow us on Twitter!
TUAW [Cafepress]

Sponsored Links

Featured Galleries

DNC Macs
Macworld 2008 Keynote
Macworld 2008 Build-up
Google Earth for iPhone
Podcaster
AT&T Navigator Road Test
Bento for iPhone 1.0
Scrabble for iPhone
Tom Bihn Checkpoint Flyer Briefcase
Apple Vanity Plates
Apple booth Macworld 07
WorldVoice Radio
Quickoffice for iPhone 1.1.1
Daylite 3.9 Review
DiscPainter
Mariner Calc for iPhone
2009CupertinoBus
Crash Bandicoot Nitro Kart 3D
MLB.com At Bat 2009
Macworld Expo 2007 show floor
Apple Texas Hold 'Em

 

More Apple Analysis

AOL Radio TUAW on Stitcher