Writing iPad apps: what you need to know
Paul Ockenden offers practical advice on building apps for Apple's tablet
Recently I looked at the iPad from a business angle, and now I want to examine designing applications for it.
There are three possible approaches: first, to write native apps, to do which you have to sign up to Apple’s iOS developer program. This costs £60 a year and, as well as the developer tools, provides access to beta releases of new iOS versions long before they go public.
If buying new hardware and learning a programming language and framework sounds too painful, the second option is to use an app platform that targets the iPad
One possible downside is that you’ll need a Mac, as Apple’s tools are, not surprisingly, Mac only (you’re about as likely to see Apple release a Windows version of Xcode as you are to see Microsoft porting Visual Studio to the Mac). You could employ some kind of Hackintosh (a way of getting non-Apple PCs to run OS X) or run OS X inside a VM, both of which are possible but breach the OS X licence conditions. Frankly, for most people they’ll be too much hassle. You’d be better off picking up an Intel-based Mac mini on eBay for a couple of hundred quid, as that will be more than adequate for writing iPad or iPhone apps.
A bigger problem may be that you need to learn Objective-C. Many C++ users expect that Objective-C will be similar, but it isn’t – it’s more like old-fashioned Kernighan and Ritchie C mashed up with some Smalltalk. I’ve heard it described as the worst bits of C with the clumsiest bits of Smalltalk laid on top, but that’s a bit harsh.
You can write C++ methods, but the Apple frameworks are all written in Objective-C, so you have to master that before you can start work with the iPad’s GUI and other bits. I’ve written a lot of C++ in the past and I find Objective-C’s lack of constructors and destructors a real pain, forcing you to initialise and free everything manually. It uses only a single namespace too, so forget public and private objects. It’s really like going back to old-school programming.
In addition to learning Objective-C you’ll also need to learn Cocoa, the framework at the heart of all iOS apps, which is philosophically very different from Windows programming (which is only natural given how different the iPad and Windows user experiences are).
If buying new hardware and learning a programming language and framework sounds too painful, the second option is to use an app platform that targets the iPad. The best known is Flash, but other specialist engines are available, such as Unity 3D and Stonetrip ShiVa3D, both of which are primarily for creating games but can also be used for other kinds of app. Both of them, like Flash CS5, enable you to develop an app on a Windows PC and then target-compile it for the iPad.
Perhaps I’m overcautious, but I’d be worried about going down this route for any high-profile project, or for one with significant manpower or financial investment because of the capricious nature of Apple’s app approval process. At first it was happy to permit apps built using third-party tools, then it banned them (causing a big spat with Adobe), then it decided to allow Flash and similar apps again, mainly to appease EU regulators.
Who’s to say this notoriously fickle company won’t change its mind again in a few months’ time? Nothing in life is certain, but given Apple’s SDK and app deployment rules I’m not prepared to bet the farm on a Flash- or Unity-based project.
You can make a browser-based app run like any other iPad app, taking over the full screen (without the address bar and so on) and employing Webkit CSS to give your app the iPad/iPhone look and feel. It can respond to gestures such as touch, scrolling and scaling, and can even put its icon on the Springboard. Best of all, you can cache your browser-based app so it will run even when the device has no internet access.
There are a few iPad quirks you’ll need to be aware of whether you’re writing HTML-based apps or just want people with iPads to access your existing website or web application. The first is that you can’t use Flash. Perhaps Apple and Adobe will kiss and make up some time, but until that happens Flash is a no-no (but I’m sure you already knew that).
Another gotcha is scrolling blocks within divs and iframes – the usual one-finger swipe gesture triggers the window.scroll() event in Safari, which makes the whole page scroll rather than just your block of text. There’s a two-finger scroll gesture available on iOS devices that does what you need, but in my experience most iPad users don’t know it exists, so I’d advise you not to scroll text blocks – at least not for important content.