A Bonjour / Chat Tutorial For iPhone Developers

May 20, 2009

MobileOrchard just published a tutorial article by Peter Bakhyryev, describing a sample iPhone app called “Chatty” that acts as a simple peer-to-peer chat-room.

“In this tutorial, we are going to explore a simple chat application for the iPhone. It allows you to host your own chat room and advertise it on your local Wi-Fi network (in which case your app acts as a chat “server”) or find and join chat rooms hosted by other people on your network (acting as a chat “client”). Both announcement and discovery of chat rooms are implemented using Apple’s Bonjour protocol. The goal of this app is to show you how to use various networking-related frameworks available in the iPhone SDK version 2.x. The UI is minimal (consisting of only 3 simple views) - just enough to be able to play with the core functionality of the app without having to deal with complex UIKit code.”

It’s a well-written overview of everything from sockets to runloops to message framing, and it happens to basically describe what my MYNetwork framework does. So an alternate way to read the tutorial is as a description of things you don’t have to worry about if you’re going to use MYNetwork ;-) Because honestly, the stuff he’s describing can be a real mess to deal with, and isn’t that the kind of thing that should be solved once and stuffed into a reusable framework?

Now I am seriously tempted to download the app, replace its networking and messaging code with MYNetwork, and see how small it comes out. If I do, I’ll be sure to post the results here.

[ Update: I actually did it. Here’s my forked Chatty