Preface

You don’t have to be an Apple fanboy or fangirl to give Apple Inc. credit for redefining mobile gadgetry and its surrounding industries. First the company used the iPod to reshape the music industry and strongly influence how we acquire and consume tunes. Just count the number of people wearing iPod-connected earbuds in a subway car. Then the iPhone rewrote the cellular telephone industry manual, while opening the world’s eyes to the potential of being connected to the Internet nearly everywhere, all the time. It’s happening again with the iPad, where electronic publishing is evolving right before our eyes.

Although the iPhone was an early success with just the workable but limited set of Apple-supplied applications that came with the phone, programmers couldn’t wait to get their hands on the platform. The first word that Apple let drop about third-party developers, however, landed with a bit of a thud: they were graciously allowed to create web apps. Sure, the iPhone’s WebKit-based browser let creative HTML, CSS, and JavaScript programmers create far more than dull web pages, but the apps still faced frustrating limits compared to Apple’s native apps.

It took some additional months, but Apple eventually released a genuine software development kit (SDK) to allow third-party programmers to create native applications for what was then called the iPhone OS. Part of Apple’s task was also creating the App Store to distribute apps—yet another industry-transforming effort. Many existing Mac OS X developers rejoiced because the iPhone OS was derived from Mac OS X. The iPhone SDK was based on the same Xcode tools that Mac developers had been using for some time. The language of choice was Objective-C.

As a happy iPhone early adopter, I eagerly awaited the iPhone SDK. Unfortunately, despite my years of being a dedicated Mac user since 1984 and a scripter since 1987 and the HyperCard days, I had never done any Mac OS X programming. I didn’t know much about C and next to nothing about Objective-C. Still, I thought perhaps my years of experience in JavaScript would be of some help. After all, at one time I even learned enough Java to write a small browser applet to demonstrate how JavaScript code in a web page can communicate with the applet. At least I knew what a compiler did.

When the iPhone SDK landed on my Mac, I was simply overwhelmed. The old metaphor of trying to sip from a firehose definitely applied. The more I read Apple’s early developer documentation, the more I felt as though I had to know a lot more than I knew just to understand the “getting started” texts. With JavaScript having been the most recent language acquisition for me (albeit back in late 1995), I looked for anything I could borrow from that experience to apply to iPhone app development. I’d see occasional glimmers, but I was basically flying blind, not knowing what I had to discard and what I could keep.

The SDK was evolving during that time as well. I’d read a tutorial here and there, but I wasn’t making much headway at first. Some tools, especially Interface Builder, felt incomplete to me. Frankly, I had a couple of false starts where I walked away until a future SDK version appeared. Finally, I reached a point that was “put up or shut up.” After sticking with it and reading many of the documents many times, I was, indeed, getting tastes from the firehose. Working on iPhone development as a part-time effort over a three-month period, I managed to go from the starting line to submitting my first app to the App Store in January 2009.

Since then I’ve been monitoring the developer communities on both the native app and web app sides. I’ve even sat in online courses for web app developers to see what they’re saying in the chat room. A lot of web app developers seem to look enviously to native iPhone and iPad development. I suspect many have gone through the same false starts that I did. And yet I know from my own experience that it is possible to make the transition from web app to native app developer if you know how to channel your JavaScript knowledge into what is now known as the iOS SDK environment.

What You Need to Start

I have written this book specifically for the web developer who is comfortable in the JavaScript language. Even if you use a bit of JavaScript to glue together apps from third-party JavaScript libraries and frameworks, you should be ready for this book. Unlike most entry-level iOS programming books, this one assumes that you have not necessarily worked in a compiled language before. You probably have little or no experience with C or Objective-C. But you do know what a string and an array are because you use them in your JavaScript work. I will be introducing you to the way Objective-C works by comparing and contrasting what you use in JavaScript. It’s the kind of hand-holding that I wish I had when I started learning iPhone app development.

You will get more from this book if you are the adventurous type. By adventurous, I mean that you will follow the instructions throughout to try things for yourself. Along the way I will help you build an app called Workbench, where you will be able to play and learn by experimenting with little pieces of code here and there. Creating projects, editing files, and building apps is the only way to really get to know the SDK.

Of course, you’ll need a Macintosh running Mac OS X version 10.6 (Snow Leopard) or later. I’ll have more details about getting set up with hardware and SDK software in Chapter 2.

Get Learning the iOS 4 SDK for JavaScript Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.