iOS

A good API wrapper should handle network transport, payload serialization/deserialization, and authentication, abstracting these details away in order to let the developer deal with the business domain of the API. Projects like Faraday, Requests, and others have made creating higher level wrappers much easier.

Perhaps even more than advanced features like GPS, camera access, contacts, and
App stores, the lack of viewport-aware position:fixed is what drives
many apps to be developed as a native experience.

Joe Hewitt who brought usFirebug and the Facebook iPhone app has
released Scrollability, a
single script with no external dependencies that allows developers to
achieve near-native feeling scrolling, just by adding a few CSS classes
to their markup. In just a few hours of its release, the project has over 250 watchers on GitHub.

Joe includes a simple demo for iOS devices that demonstrates super smooth scrolling as well as fixed header and footer elements.

However, if you do speak Objective-C or Java you might not know you can extend Titanium and provide JavaScript hooks for your own code that you might want to share with other projects (and even other folks) via custom modules. You can even build extensions in JavaScript as well. The Ti+Plus Modules Starter Pack is a bundle of sample projects demonstrating how to extend Titanium. The source code for these projects augment the iOS module development and Android module development guides on the Titanium documentation site.

Be sure to check out the sample source for Flurry, Paint, and this one from AdMob:

#import "TiAdmobModule.h"
#import "TiBase.h"
#import "TiHost.h"
#import "TiUtils.h"
@implementation TiAdmobModule
// this is generated for your module, please do not change it
-(id)moduleGUID
{
return @"0d005e93-9980-4739-9e41-fd1129c8ff32";
}
// this is generated for your module, please do not change it
-(NSString*)moduleId
{
return @"ti.admob";
}
#pragma mark Lifecycle
-(void)startup
{
// this method is called when the module is first loaded
// you *must* call the superclass
[super startup];
NSLog(@"[INFO] AdMob module loaded",self);
}
-(void)shutdown:(id)sender
{
// this method is called when the module is being unloaded
// typically this is during shutdown. make sure you don't do too
// much processing here or the app will be quit forceably
// you *must* call the superclass
[super shutdown:sender];
}

URLs are one of those things about the web that we often take for granted. As developers, we can request resources and send users to other destinations just by knowing a location on the Internet.

The mobile landscape is a bit different. While most mobile applications speak Web, consuming REST-ful APIs and other web resources, quite often they’re little silos of vertical, site or brand-specific functionality. Did you know that for iOS developers Apple makes it possible to register your own URL scheme, as in this Gowalla example:

Beyond application launching

As handy as these custom iOS URL schemes are in launching other applications, mobile developer Greg Pierce wants to the community to extend the idea of custom URL schemes and adopt a standard for inter-app communication. X-Callback-URL is a draft specification for one-way and two-way communication between mobile apps on iOS and looks like this:

Let’s look at a real world example from Greg’s popular Terminology, a language reference app for iPhone and iPad:

terminology://x-callback-url/1.0/lookup?text=a%20good%20deal

scheme: The app’s custom URL scheme, terminology in the above example

host: Callback URLs are identified by a host value of x-callback-url

version: The X-Callback-URL spec version, currently 1.0

action: The action to perform in the target app. In this case, Terminology will perform a lookup action.

x-callback parameters: Optional. Not used in this example

action parameters: The parameters to pass to the executing action, “a good deal” in this example

This approach provides a robust way to not only launch an app, but also request that the app handle an action, which may or may not have a UI associated with it.

Two-way communication

The real power of X-Callback-URLs lies in two-way inter-app communication. By using the x-callback parameters in the spec, we can ask the target app to call us back on our own URLs, even handling success and error scenarios. Sort of like custom HTTP headers, these callback parameters are identified with an x- namespace:

x-source : The friendly name of the source app calling the action. If the action in the target app requires user interface elements, it may be necessary to identify to the user the app requesting the action.

x-success : If the action in the target method is intended to return a result to the source app, the x-callback parameter should be included and provide a URL to open to return to the source app. On completion of the action, the target app will open this URL, possibly with additional parameters tacked on to return a result to the source app. If x-success is not provided, it is assumed that the user will stay in the target app on successful completion of the action.

x-error : URL to open if the requested action generates an error in the target app. This URL will be open with at least the parameters “errorCode=code&errorMessage=message. If x-error is not present, and a error occurs, it is assumed the target app will report the failure to the user and remain in the target app.

Here’s how you’d build a URL to allow your users to select some text in your app, choose a replacement in Terminology, and have to return back to your app.

A new breed of mobile devices led by the Apple iPad are changing the way we think about web layout. Applications like Flipboard and Feedly have led the charge in a resurgence of magazine-style layouts both on the web and on the tablet.

Treesaver from Filipe Fortes is a new JavaScript framework for creating magazine-style layouts using standards-compliant HTML and CSS. Weighing in at just 25KB, Treesaver’s feature set is impressive providing support for grid and column layouts, custom UI’s, repeating content, cover pages, figures and illustrations, and analytics.

Be sure and check out the impressive demos, especially on the iPad. With this first public release, Filipe admits the project still needs a lot of work. But the GitHub repo has a deep wiki and is very active. If you’re interested in contributing, you can help knock out the growing list of bugs and features.

Interface Builder is one of the coolest things about Cocoa development. Being able to draw your interfaces visually can save you tons of otherwise tedious code to create layouts and set visual styles for your user interface elements.

Bonus #2

But wait, there’s more. We also stumbled across Adrian’s other project Bluwoki, a Bluetooth peer-to-peer walkie-talkie for iPhone and iPod Touch. Since my daughters get their Dad’s old hand-me-down iPhones, I may have to install this for them to have some fun around the house. Bluwoki is also open source, grab the code on GitHub.

While language purists might balk at the growing popularity of projects that compile to Objective-C, the verbosity of the Cocoa framework has many developers looking for a faster way to create iPhone apps. Let’s face it, the vast majority of apps in the App Store follow a familiar pattern of making a network request, showing an activity indicator, parsing a JSON response, handling errors, loading a UITableView, and handling navigation to the next bit of data.

Behind most every App Store download, there is a painful trail of ad hoc beta builds as developers send beta bits to users to gather feedback and fix bugs. Luke Redpath, UK Rubyist and iOS developer, aims to ease that pain for iOS developers with BetaBuilder, a Ruby gem that bundles up a collection of rake tasks to make it easier to deploy your iOS apps.

BetaBuilder supports distributing your apps own your own server or using TestFlightApp.com. To get started, first install the gem:

The folks over at Appcelerator have been busy, recently releasing version 1.5 of their Titanium Mobile platform that enables developers to create native iOS and Android applications using JavaScript.

In the spirit of showing versus telling, they’ve released Tweetanium, a Twitter client and cross-platform showcase of the Titanium platform.

Tweetanium is an excellent example of how to build real-world applications with Titanium and demonstrates JavaScript best practices, including the module pattern, API integration with Twitter, as well as advanced CSS3 techniques.

If you missed it, be sure and catch Episode 0.0.8 in which Marshall Culpepper gives us the scoop on the Titanium architecture.

Our weekly list of projects you might have missed on GitHub: RestKit RestKit is a nice high-level library for consuming REST resources in Objective C. It runs on OS X and iOS and provides three major features: Network transport including GET, POST, PUT, and DELETE Object mapping between JSON responses and local domain types, in […]

Wynn caught up with Thomas Fuchs to talk about script.aculo.us, Scripty2, Zepto.js and the future of Prototype. Items mentioned in the show: The Magic Roundabout is crazy Wynn got his UK badge on Gowalla script.aculo.us JavaScript effects framework built on top of Prototype Prototype – JavaScript Framework that aims to ease development of dynamic web […]

One reason JavaScript frameworks have become popular is because they abstract browser differences and let the developer focus on the work at hand, not on how it’s done. Since zepto.js targets only Webkit browsers, a lot of the cruft found in other frameworks can be eliminated. Modern JavaScript features such as forEach can be assumed so the framework is leaner, critical for building mobile apps.

zepto.js is under heavy development (growing by 2x since we first spotted it yesterday), but looks to deliver on its goal of being a “~2k library that handles most basic dredge work for you in a nice API so you can concentrate on getting stuff done.”

Features

zepto.js uses the familiar $ function and includes the usual suspects:

get(): return array of all elements found
get(0): return first element found
html('new html'): set the contents of the element(s)
css('css properties'): set styles of the element(s)
append, prepend: like html, but append or prepend to element contents

Ajax support

Methods you’d expect for Ajax-fied GETs and POSTs are there as well:

$.get(url, callback)
$.post(url, callback)
$.getJSON(url, callback)

Installing and using

Thomas recommends not linking to zepto.js directly in your document <head>, rather copy and paste the contents of zepto.min.js directly into a <script> tag.

Thomas knows a thing or two about mobile optimization. Be sure and catch his thoughts in how he optimized Every Time Zone for mobile devices.

(n.) – a slang word for a computer tablet such as the iPad or other branded tablet devices

Unlike Sencha’s JavaScript-centric approach, Slablet opts for a more unobtrusive implementation. Content is created in HTML, styled with CSS, and driven by jQuery. The project uses iScroll to provide overflow:scroll in its fixed height elements.

Facebook loves iOS developers. First, they gave us Three20, a nice iOS app framework extracted from their popular native app. Now they’ve released the Facebook iOS SDK which lets you easily add authorization, API calls, and Facebook dialogs to your iOS apps.

Authorization

To authorize a user using OAuth2 you can simply create the Facebook client and call authorize