Archive for September, 2009


Tip: Xcode function marks

Here’s a handy tip for all you non-C-based-language Xcode users out there; if you wished that you could have helpful comments in your function popup lists like C-based languages do with

#pragma mark Text here

it turns out that, as a matter of fact, that capability is built into the Xcode editor! In C-based languages, any comment line that starts with

// TODO: Text here
// FIXME: Text here
// MARK: Text here
// !!!: Text here
// ???: Text here

will insert the commented text in the popup just as if you’d typed out #pragma mark. Which saves a few keystrokes, whoopie; however, apparently the same trick also works for native comments in Java, Perl, Python, and Ruby! Helpful little convention to adopt, then, we believe we’ll start doing that everywhere.


Review: Things

OK, this isn’t a “review” really, just a flat out recommendation — buy Things for the Mac and Things for the iPhone, they’ll improve your life.

As you can probably imagine even if you’re not one, being a freelance contractor, and particularly a freelance contract iPhone programmer, involves juggling a vast array of conflicting projects, usually running at least three levels of interrupt deep. And although over the years we’ve dabbled at many, many forms of online and offline organization, most popularly these days some kind of derivation of the GTD™ cult (which if you’re part of, check out this collection) they’ve all ended up in short order being either too unwieldy to be actually useful, too structure-imposing to actually match the real world, or too consumed on process as a substitute for actual achievement … and we end up actually using the good ol’ Stuff To Do piece of scrap paper tucked under the keyboard.

Until now!

We’d been noticing rave reviews of the simplicty of Things popping up all over the web (just check the product pages above on the right for lots of examples, a particularly good one here) but the goodies list here was the one that finally roused us enough to figure hey, if the desktop and iPhone versions actually worked well together, this could finally be one that was worth the effort to get into. And shocked, shocked we were to find that it not only had a learning curve approximating zero, it was actually less overhead than paper. Six days into running it now, and it’s completely taken over running our life, as it works just the way we do … but easier. Amazing, that.

The only thing that comes close to a flaw is that we’d like to see MobileMe (or whatever) sync so that our various computers, iPhones, and iPods could all share state through the cloud with complete transparency. But hey, even without that, it’s still the best — nay, the first and the only — personal task-management software that actually helps us manage tasks as opposed to having us fiddle with managing tasks. Matter of fact, it’s pretty much verging on killer app status for the iPhone platform, that’s how good we think it is … and if your life is anywhere near as unavoidably unstructured as ours, we’re pretty sure that you’ll agree!




So if you bothered reading that last post about lickety-split XML parsing, you might have noticed the references in the referring article to “the Tiled map editor” which apparently was the producer of the XML in question. That didn’t perk our interest quite enough to track it down … but turns out there’s a companion post that makes the noteworthiness of Tiled, a generic tile map editor quite clear:

Tiled is a general purpose tile map editor. It’s built to be easy to use, yet capable of catering to a host of varying game engines, whether your game is an RPG, platformer or Breakout clone. Tiled supports plugins to read and write map formats, in addition to its map format, to support map formats in use by engines.

Not quite seeing the noteworthiness yet? Well, here you go. As you may recall, we’re fans of the cocos2d library around here, but we’d managed to overlook recent developments; turns out that as of v0.8.1 back at the end of August, support for Tiled maps is baked in for orthogonal and isometric maps! As writing your design tools and designing their data formats takes up a huge chunk of game development effort, anything that speeds that along is A Good Thing; and it certainly does seem that between cocos2d, the Tiled editor, and TBXML to speedy things up, you’ve got a pretty sweet open source game development environment taking shape here, doesn’t it?


Library: TBXML

Here’s a new tool for your iPhone bag of programming tricks: the TBXML library. Yep, an XML parser, eponymously enough; and why do we draw attention to yet another of those? Why, because

TBXML is a light-weight XML document parser written in Objective-C designed for use on Apple iPhone / iPod Touch devices. TBXML aims to provide the fastest possible XML parsing whilst utilising the fewest resources. This requirement for absolute efficiency is achieved at the expence of XML validation and modification. It is NOT possible to modify and generate valid XML from a TBXML document and NO validation is performed whatsoever whilst importing and parsing an XML document.

Well, that suits a good number of applications. As discussed on 71^2 here:

… the difference is speed is truly amazing. The TMX file I was passing was taking between 15-20 seconds and with the new parser its down to 600ms …

… It also supports gzip as well … This brought the file size down from almost 2MB to 4KB.

Yep, that’s a pretty epic win alright, multiple orders of magnitude reduction in both space and time. Not bad indeed. If you have an application with significant static data requirements, this looks like a mighty compelling approach!


iPhone OpenSSL

So if you have any desktop code that involves secure communications, chances are pretty darn good that it involves the OpenSSL library. And when you begin to port said code that involves secure communications to the iPhone, you promptly find … it’s not there! At least, for a value of “not there” which is “not exposed in the official SDK”. Issues with encryption export, it seems; apparently Apple’s own apps using encryption on the phone doesn’t cover third party apps? Or something. But for whatever reason, it’s not there, and you have to build your own. And here we have some help for you with that:

Tutorial: How To Compile OpenSSL for the iPhone

Walks you through getting the source, sorting out iPhone architecture settings, and building it. Or, if you have a troll’s attitude to work, skip straight to the last paragraph:

Some people had some questions about how to use the libraries in an Xcode project. Here is a simple xcode project including just the linking of the libraries and adding of the header files: openssl_tutorial

For the lazy people. Compiled libraries: compiled_libraries

Although his nomenclature needs a little bit of work. It’s not about being “lazy”. It’s about being efficient. Although, granted, the line can be fine indeed.

As an alternative, if you’d like to integrate it into your Xcode build process, check out

Tutorial: iPhone SQLite Encryption With SQLCipher

which includes the aside

OpenSSL can be a tricky system to compile properly from source. It’s even more complex when you’re dealing with multiple target architectures, targeting i386 for the simulator but armv6 for a device. Luckily we’ve built a handy XCode project template to make it easy called openssl-xcode. The project actually relies on the OpenSSL configure and make system to build the libraries. However, it automatically detects the appropriate build settings for architecture (i386, ppc, arv6), build tools, and SDK. This makes it ideal for inclusion in an iPhone project. Just git clone or download openssl-xcode from GitHub and move the openssl.xcodeproj file into the OpenSSL source directory.

We’re quite satisfied with just linking straight to the prebuilt libraries and pretending like we’re linking to system libraries on the desktop … but hey, if you want complete build control, there you go!


HTML5 Intro

So you’ve no doubt noticed references here and there to the nifty new HTML5 stuff that’s working its way out into the world, but there’s been a positive dearth of good introductions out there, as opposed to snippets trickling out here and there; well, here’s a good start on sorting that from our friends at Google:

Video Introduction to HTML5

We’ve put together an educational Introduction to HTML 5 video that goes over many of the major aspects of this new standard, including:

  • Web vector graphics with the Canvas tag and Scalable Vector Graphics (SVG)
  • The Geolocation API
  • HTML 5 Video
  • The HTML 5 Database and Application Cache
  • Web workers

In the video we also crack open the HTML 5 YouTube Video prototype to show you some of the new HTML 5 tags, such as nav, article, etc. It’s chock full of demos and sample source code.

Well worth the watch. Especially in light of the news that Google is going to drag Internet Explorer users kicking and screaming into the current millennium by, essentially, delivering WebKit as an IE plugin. They must be feeling pretty nervous down in Redmond these days!

[EDIT: And here's another link-laden HTML5 overview worth checking out!]


Library: 3D Globe

Here’s an interesting — if somewhat niche — licensable library just released for your iPhone programming: an interactive 3D globe!

Some of the features of the globe are:

  • Zooming and navigation of the globe with standard iPhone gestures
  • Smooth rotation between two sets of GPS points
  • Multiple high resolution texture maps of the globe
  • Textures that shows country borders and names
  • Adding effects on the globe at a given set of gps coordinates. This can be a glowing effect or drop pins like on a travel map
  • Code is well comment and structure so that it is easy to extend
  • Ability to double tap on the screen and have the code translate the tap into the GPS coordinates of that location

Just the thing if you need it, indeed. Not that one often does we suppose, but hey speaking for ourselves one of these days if we ever find the time to do that iPhone client for we’ve been tossing around the idea of doing, we’d definitely look into this 3D Globe thingy some more. In the meantime, there’s a free app available to show the globe in action, an iPhone interface to what looks like a most fascinating travel website that we had not previously been aware of,

Planning a trip? Find local help in 165 countries! Ask Questions. Book Services…

We created because many of the best travel experiences start with getting to know a local person like you. brings travelers and Localytes together to promote authentic travel experiences….

Localytes are local people who are proud of where they live and want to share their local knowledge with Travelers.

As it happens, we’ve just been contemplating taking a break in the nearish future, and this certainly does look like an interesting site to look into in more depth. So if you are interested in either traveling or becoming one of their localytes, or just want to check out how 3D Globe performs … hey, the app is free!



Source: iPhoneDevCamp 3

Here’s a good selection of open source that we’d missed ’til now: Several of the winning projects from iPhoneDevCamp 3′s Hackathon have their source available online. Stuff like:

iPhone ARKit

An open source ui library for displaying location based data in spherical coordinate systems mirroring UI Kit on the phone. A list of CLLocation objects can be submitted and our library will handle drawing of the locations on screen.

OpenFlow: a CoverFlow API replacement for the iPhone

A free, open source replacement for Apple’s private CoverFlow API. The initial release is simple, but it is also efficient and very fast, even on first generation iPhones.

Avatar Wall

AvatarWall recreates the experience of the WWDC App Wall using the Twitter avatars of iPhoneDevCamp followers, and whenever one of them posts a tweet, their icon pulsates to help you more easily identify the source of the latest banter.

Lots more too — read the whole list!


Tip: First Responder

So you ever found yourself thinking “gee, it would be really handy to know what the first responder is right now” and wonder why you couldn’t find what must be the quite obvious call to get it? Well, we did, and it turns out no, there actually is no supported way to do it far as we can tell. But if you really really need to figure it out, Matt Gallagher is on the job:

This is an important piece of information, so it’s strange that Apple didn’t choose to provide a public method to access it. Curiously, there is a method, firstResponder, on UIWindow which returns this value but it isn’t public. This will work:

UIView *firstResponder = [[UIApplication sharedApplication] keyWindow] performSelector:@selector(firstResponder)];

Now, you do have the UIResponder isFirstResponder method publicly available if you want to query about a specific view you know about, but the generic case, nope. Most likely because arbitrary access would get you closer to the dreaded “There is no documentation for the custom subclasses or self-contained views of…” rejection notice, I suppose. But hey, if you want to know how, there you go.
Also of note in that article is code for finding the keyboard, drawing round rects, and providing a nice-looking progress view; good stuff all!


Roundup: Push And Purchase

(Alright, this isn’t a “roundup” as we post this, since it’s pretty much just the links from this fine, fine post at NSCoriolisBlog — but hey, we’ll be editing as developments occur!)

So as you’ve noticed no doubt if you’ve even cursorily looked at how to go about implementing push notifications or in-app purchasing in your sparkly new cutting-edge iPhone apps … there’s a lot to do there. More importantly, you can’t just toss your binary up to Apple and forget about it any more, there’s ongoing service and scalability issues. That’s a pretty big leap in project complexity. However, there are services that are springing up to take care of the hassles for you! The two that are actively deployed and providing push and purchase both are

Urban Airship — got all the big name clients so far

iLime — make a big production about being cheaper for messages

Both charge 5 cents a download for content, it seems.

As well, there’s several upcoming competitors in beta:

Bigcurl HTTPush



[EDIT: AppNotify -- thanks, Josh!]

Seems like a few too many gearing up there for what the size of the market is likely to be. So although in line with the programmer’s natural desire to avoid work we thoroughly recommend getting started with one of these services, we suspect that if we actually ended up depending for our livelihood on a particular product we’d want to go through the trouble of getting our own host set up to remove this possible point of failure, at least unless/until one of them is clearly profitable enough to stick around for the long term. And so, here’s some links to help you out with that:

Tutorial on how to setup your own server in PHP

Source code (in PHP), requires PHP with memcache

Python wrapper for Apple Push Notification Service

Apple Push Notification Library for Haskell

Apple Push Notification Library for Ruby

Apple Push Notifications on Rails

Apple Push Notification & Feedback Services Client C# Library

And again, our grateful acknowledgement to NSCoriolisBlog for providing all the links for the first edition of this “roundup”!