Download the new Switched app for your iPhone

Skip to Content

Stay up to date with Switched's CES 2010 coverage
AOL Tech

Filed under: iPhone

Journeys inside the iPhone's SDK

I have now spent a pretty solid week writing applications for the iPhone. And what an exciting week it's been. I've been privileged to view and interact with the iPhone in a way that few other people have had the opportunity to. The iPhone is tight, robust and its SDK--even seen through such imperfect tools as class-dump--is beautiful.

Let me give you an example. This morning I decided to write a basic word processor for the iPhone. In about 30 lines of code, I was able to create an application that saved all changes to disk and reloaded that text launching the application. That kind of success doesn't happen because I'm some sort of phenomenal programmer, it happens because Apple makes amazing, usable libraries. I was able to use classic Cocoa strategies like reading a string to and from disk and combine it with new UIKit strategies like creating a keyboard that automatically knows how to enter and edit text.

The hardest part of the process was figuring out how to know when the iPhone Application was about to quit. I fumbled around for a while trying to use standard Cocoa delegates, like "applicationShouldTerminate". In fact, I should have gone straight to the UIApplication include file instead of trying to "Think Cocoa". The correct delegate was applicationWillSuspend. This reorientation of the discovery process is important. The iPhone is not a Macintosh. Its vocabulary, libraries and frameworks reflect that difference.

I've put all the source code for the TextEdit app up over at Textmate.org. If you're interested in looking through the code, here's the Makefile, mainapp.m, SampleApp.h, and SampleApp.m. Or you can find all four on our iPhone hacks page.

As you can see, the application basically sets up a UIWindow, allocates it and establishes its bounds. It then adds a main UIView and to that view adds two subviews: the text and the keyboard.

I added persistence (the way the application remembers its text from one time to the next) with two lines, both provided by NSString. The first writes the string to a file, the other creates a string with the contents of that file. That's a pretty awesome amount of power for two lines of code and again shows why Apple rocks.

Click here to read all TUAW’s iPhone coverage
jobs & resumes
iPhone / Android Developer

Bump Technologies, Inc. - Mountain View, CA (2 weeks ago)

See More Relevant Jobs ›

Related Articles From Our Partners

Reader Comments (Page 1 of 1)

Tip of the Day

Want to drag a file to another folder and copy it instead of moving it? Press the Option key when you drag that file and it'll be duplicated rather than moved entirely.

Follow us on Twitter!

TUAW [Cafepress] 

Featured Galleries

DNC Macs
Macworld 2008 Keynote
Macworld 2008 Build-up
Google Earth for iPhone
Podcaster
Storyist 2.0
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

 

Our Writers

Victor Agreda, Jr.

Programming Manager, AOL Tech

RSS Feed

View more Writers

More Apple Analysis

AOL Radio TUAW on Stitcher