Under the Bridge

Tutorial: NSUndoManager

Happy New iPhone Day, everybody! And as the first in what’ll no doubt be a veritable tsunami of OS 3.0 SDK-related posts, Mobile Orchard is promising a series of “New in iPhone 3.0″ tutorials, and the first one is the definitely worthwhile Shake To Undo/Redo, NSUndoManager:

Undo/redo capabilities are provided by the NSUndoManager class. The class, documented here, works by keeping a stack of messages that, if sent, would serially undo the last action, the penultimate action, and on back until arriving at the initial state.

Let’s use an example to illustrate how this works: our city, concerned with a perceived increase in the number of trucks plying our streets, has commissioned a census. City workers will tally truck traffic using an iPhone app. See a truck, tap a button. Oops! Mistook that Subaru Forester for a truck? Shake to undo.

We’ll start with working code that lacks undo/redo and add those capabilities…

Read and learn!

Continue Reading →

Tips: UITableView

Here’s a selection of UITableView advice and code for you:

Easy custom UITableView drawing

Customizing your UITableView can be really easy. You don’t need custom drawing code. You don’t need subclasses of anything. Cocoa Touch provides all the drawing capability you need, all you have to do is use the right classes in the right ways and provide the layout.

Fast Scrolling in Tweetie with UITableView

Scrolling is the primary method of interaction on the iPhone. It has to be fast. It has to be fast. More than a few developers have asked me how I do it in Tweetie, so I figured I would share a really fast and really clean technique people can adopt in their own apps.

ASKit from Enormego’s open source

ASKit is an easy to use library for your iPhone applications. ASKit provides AppStore styled table views

UITables with Downloaded Images – Easy Asynchronous Code

Multi-threaded programming is hard and should be avoided whenever possible, and in this case Cocoa’s beautiful design came to my rescue: UIView heirachy + URL loading system + delegate design = multi-threaded image loading with no multi-threaded coding!

Drill down table view with a detail view

Using a drill down table view we can display hierarchical data where the last view is responsible of displaying some detail information. This view in which the detail information is displayed can be the same for all the data in the table view (like my last tutorial) or it can be different based on the path that the user took. In this tutorial I will show you how to add a different detail view based on the path the user took to get to the last item …

Lots of good stuff there, enjoy!

[EDIT: Check out ABTableViewCell, in Fast Scrolling in Tweetie with UITableView!]

Continue Reading →

Tip: Crash Reports

OK, maybe it doesn’t quite count as a “tip” exactly to tell you to read an Apple tech note, specifically

Technical Note TN2151
Crash Reporting for iPhone OS Applications

… but just in case you haven’t stumbled across it so far, there’s a particular point that you need to be aware of before you submit your next iPhone application build to Apple, which we figure pushes this into the tip-worthy category:

…Unlike crash logs from Mac OS X, iPhone OS logs do not contain symbol information when they’re written out. You have to “symbolicate” iPhone OS logs before you can analyze them.

Symbolication – resolving stack trace addresses to source code methods and lines – requires the application binary that was uploaded to the App Store and the .dSYM file that was generated when that binary was built. This must be an exact match – otherwise, the report cannot be symbolicated. It’s essential that you keep each build distributed to any users (regardless of mechanism) with its .dSYM file.

IMPORTANT: You must keep both the application binary and the .dSYM file in order to be able to fully symbolicate crash reports. You should archive these files for every build that you submit to iTunes Connect. The .dSYM and application binary are specifically tied together on a per-build-basis, and subsequent builds, even from the same source files, will not interoperate with files from other builds.

Given a crash report, the matching binary, and its .dSYM file, symbolication is relatively easy…

Now you know!

Continue Reading →

Resources: Open Source

Let’s list off today some sites worth checking out for iPhone/Mac programming open source goodies should there not — heaven forfend! — be anything particularly appropriate already mentioned in the annals of this humble journal. Hard though that is to imagine of course!

And for a vast list of iPhone-devoted not only open source projects but everything from LinkedIn groups to useful blogs (why, it even lists us! How sweet!), the pithily named

iPhone Resources

is not to be missed.

As always, if there’s anything noteworthy we’ve missed, comment away!

Continue Reading →

Vector UI design

Now this has some excellent potential for improving our work with designers: the charming people over at Mercury Intermedia have released a set of iPhone UI vector elements for your Illustrator-using pleasure!

Rather than cry over the lack of good vector elements, we took it upon ourselves to recreate a large portion of the iPhone’s UI elements so we would have them available for future projects. Obviously, we aren’t telling you all of this just to wave it in your face and tell you we have fancy tools that you don’t. Because we care so much about our fellow iPhone developers, we are making our vector files available to you today. (I think I just made myself throw up a little.)

And people say we have attitude. Ha! This Rusty fellow seems like he’d be excellent company indeed for a drink or twenty. But yes, the file is well worth the download. Also note references to

iPhone GUI PSD (Photoshop)

Ultimate iPhone Stencil (OmniGraffle)

Now, if someone would write an importer to transmogrify designer-created Illustrator files directly into .xib files, then we’d really have something going…

h/t: WebResourcesDepot!

Continue Reading →

Resources: Chipmunk

So a while back we rounded up resources for the Cocos2d sprite library, and a fine library it has turned out to be too; now we’re getting into figuring out the Chipmunk physics library that it comes with, and that deserves its own resources post. It’s a bit slim, so if you have more to add, please do. But for now:

First off, the project home page for videos, tutorials, and the latest links.

Currently the source is hosted at Google Code.

Start out reading with the official documentation and the repository wiki.

Excellent tutorial to follow through next here.

And when you have more questions, the nicely active development boards are here!


The Chipmunk SpaceManager is a helper for cocos2d; source on Google Code.

The Chipmunk author has an Objective-C binding for sale, at $199.

VertexHelper is a tool for graphically defining Chipmunk or Box2D sprite vertices.

Continue Reading →

Code: AQXMLParser

Got a big (like, 22 MB) XML file to parse on the iPhone? Want to reduce the memory usage from NSXMLParser’s huge (like, 123 MB) virtual memory usage by several orders of magnitude down to almost nothing (like, 68 kb)?

Yeah, we thought you did.

The magic trick is to use “Alan Quatermain”s AQXMLMemoryParser:

Here’s the output. I think it shows that AQXMLParser is going to be *lovely* for the iPhone. Mwa-ha-haa.

Testing NSXMLParser from URL...
Parsed 200000 numbers
Peak VM usage: 128991232 bytes

Testing NSXMLParser with mapped data...
Parsed 200000 numbers
Peak VM usage: 130035712 bytes

Testing AQXMLParser...
Parsed 200000 numbers
Peak VM usage: 69632 bytes

That’s right, the NSXMLParser variant (calling xmlParseChunk() with all data at once) uses 123-124MB, while AQXMLParser (calling xmlParseChunk() with 1KB at a time, not loading all data anywhere) gets 68KB.

In short: AQXMLParser == T3h w1n!

Indeed. Source is in AQToolKit on github which is just full of all sorts of other useful goodies as well. Note also author’s blog for background.

h/t: iPhone Development!


Check out parsing example here. As referred by this chuckle-worthy post.

Continue Reading →

Source: Bickboxx

Here’s another open source project for the iPhone that may catch your interest: the available-on-the-App-Store Bickboxx is open sourced on github:

Our vision with Bickboxx is to build a community of developers for source code sharing, discussion about building iPhone applications, and resource sharing.

When you go to build your first iPhone app or your 100th…you have a great resource to start with Bickboxx.

We’ll be adding more and more features to Bickboxx and committing them to the github.com repository…

We’ll also be posting more tutorials about how we added these features to TheAppleBlog.com. So feel free to kick back, grab a fork (pun intended) and contribute some great open source code!

My, they’re bright-eyed fellows over there, aren’t they? Always amusing, er we mean inspiring, to see such sparkly enthusiasm, indeed.

Continue Reading →


Here’s something that our web programming friends will probably find of intense interest, and real programmers (we kid, we kid) may be mildly curious about as well: it’s called NimbleKit, and it’s … well, let’s let them describe themselves:

NimbleKit is the fastest way to create applications for iPhone and iPod touch.
You don’t need to know Objective-C or iPhone SDK.
All you need is to know how to write an HTML page with Javascript code.

They do claim to have some fairly comprehensive  feature support,

  • Native iPhone interface elements
  • Full control of application appearance
  • Play bundle audio files
  • Play audio streams from the Internet
  • Support iPhone vibration
  • Support Address Book with full search and people picker
  • Access to bundled files
  • Check Internet availability
  • Location services (GPS)
  • Access to images (take photo or browse in library)
  • And much more…

Indeed. We’re not quite intrigued enough at the moment to bother downloading it ourselves, but hey if you are, be sure and let us know what you think!

Continue Reading →

Tip: Firmware Downloading

Ever tried to find a particular version of iPhone/iPod firmware on Apple’s servers? Yeah, good luck with that. But courtesy of this iPhoneSDK thread we have a couple of handy places to take care of finding the right one for you:

Handy if you need it!

Continue Reading →
Page 91 of 117 «...6070808990919293...»