Under the Bridge

iPhone JavaScript Cookbook

So as promised when we posted reviewing opportunities for you a couple days back, here’s our just barely too late review of Packt Publishing’s iPhone JavaScript Cookbook — “Clear and practical recipes for building web applications using JavaScript and AJAX without having to learn Objective-C or Cocoa.”

Screen shot 2011-10-01 at 1.28.24 PM.png

Definitely targeting the, ah, ideologically vigorous portion of the developer community; the preface tells us

This is the book for any iPhone developer looking to side step the totalitarian application store regime of Apple.

Indeed. The funny thing is there, lately we’re hearing more and more of people getting rejected by ‘the totalitarian application store regime of Apple’ because their app doesn’t include any functionality that can’t be delivered by a web app. So substitute “being forced to” for “looking to” and that’s the perspective we’re evaluating from, in case it turns out that we ever get one of those rejections; as well as looking for useful tips that can be applied to delivering program functionality inside UIWebViews.

As the title would indicate, it’s organized in the snippet-collection cookbook format, but rather different from most of those we end up reading; the examples are scattered among a collection of different frameworks rather than focusing on one environment. The environments they have you install are:

Pretty decent cross-section of the various options you have for approaching JavaScript app development, yep. Not completely sure what we think of that; it works not badly for a general purpose introduction to provide the flavour of the different frameworks, but if you already have a specific environment in mind it rather reduces the value of the rest. Let’s take a specific example, the ‘Adding Visual Effects’ recipe from Chapter 3:

… Combining these movements with color changes, we can apply visual effects to the user interface of our web applications. The most popular of these animations or effects are fade and slide. Both of them display different elements on the screen showing one element and hiding another one that is applying a transition…

Yes, that absolutely is a recipe we would like for our web app to look native…

… We’re continuing with Sencha Touch because this toolkit implements some visual effects, which are ready-to-use for some elements of the user interface…

… but if you’re not using Sencha Touch, that’s not a very useful recipe, is it? On the other hand, if you’re not set in your ways yet, it’s an indication that if you do want to focus on visual richness, perhaps Sencha Touch would be a particularly good choice. So does this approach make for a useful overview or an annoying dilution of content? Your call. For dilettantes in the JavaScript world like us, we’ll go with useful overview.

And there certainly are lots of recipes that aren’t tied to a specific framework as well; for instance, the quie useful if you don’t know how ‘Running your web application without Internet access’ recipe is pure HTML 5, nothing specific to iPhone or iWebKit the particular framework used in the example. And they cover nicely the Mobile Safari requirements for icons and splash screens and so forth which are iPhone but not framework specific; so there’s certainly plenty of content that you’re likely to find useful no matter what your environment.

The actual categories of recipes, well the Preface does a fine job of describing them:

Chapter 2, Building Interfaces, introduces you to the world of iPhone applications. You’ll learn how to build essential and advanced interfaces, such as buttons, lists, forms, and date pickers.

Chapter 3, Events and Actions, discovers how to deal with events and actions. Both allow us a better control of the interaction between the user and the device.

Chapter 4, A Picture Speaks a Thousand Words, takes advantage of the great screens of iPhone and iPad teaching you how to display a grid of images, how to apply different effects, and how to work with the built-in camera of the device.

Chapter 5, Mastering Sound and Music, explores the audio and video capabilities of iPhone. You’ll learn how to play and record audio and how to create iPod playlists.

Chapter 6, Exchanging Data: AJAX, covers how to use this technology for exchanging data between the server and the client. Readers are walked through the process of sending HTTP requests and processing JSON responses.

Chapter 7, Working with Data: Storage and SQL, provides coverage of the process for storing and retrieving data using the SQL language. Also, you’ll learn how to deal with different kinds of storage available in iPhone.

Chapter 8, This is a Phone, enlightens that we cannot forget that iPhone is a smartphone. This is the reason to get focused on learning how to create, select and display contacts, and how to call a number and send an SMS.

Chapter 9, Location, Location, Location, introduces to readers to geolocation, showing how to detect the current orientation and position, and how to use the API provided by Google Maps for displaying a map at a specific location.

Chapter 10, Web 2.0 Integration, helps readers learn how to integrate their iPhone applications with third-party popular services such as Facebook, YouTube, Twitter, and Flickr.

One thing that does need noting is that a good number of these recipes for accessing native things like the camera or the address book rely on the native bridging functionality of PhoneGap. So whilst ‘without having to learn Objective-C or Cocoa’ is true, the ‘side step the totalitarian application store regime of Apple’ bit is rather given the lie, as PhoneGap produces native applications for its various OS targets and so you’re not side stepping anything. Saving some porting time, at best.

So overall? Almost certainly you’ll find at least some things of use here no matter what your experience level is, given the potpourri of Safari Mobile tips, HTML5 tips, native bridging tips, and framework-specific tips; so it would be a decent choice to add to your reference collection for anybody doing pretty much anything with JavaScript and the iPhone, we’d say.

For someone like us in particular who has as little knowledge of JavaScript as they can possibly get away with but wants to keep somewhat abreast of the state of development options in the non-native world, why yes this is a very educational book indeed, recommended without reservation.

But, well, the flip side of being generally useful to pretty much anybody is that it probably won’t be a must have for anyone in particular; and given how many of the recipes are tied to particular frameworks — particularly the ones that are tied to PhoneGap, which makes them native applications not web applications — can’t quite recommend it unconditionally to everyone. But certainly a very solid indeed four stars, and deserving of your serious consideration if you’re doing any iPhone JavaScript work at all!

0