Archive for October, 2008


Code: SMTP Client

Ever wondered about how to send email directly from your iPhone application? Personally, we’re big fans of the do a POST to your server and have it send the mail for you method on the occasions when we’ve had the task of doing something of that sort, but in case you’d prefer to have your application completely standalone, today we point you at the skpsmtpmessage library newly posted on Google Code:


This code implements a quick class for sending one off messages via SMTP on the iPhone. Will probably work under Cocoa on Mac OS X as well.

Simple and to the point. And so is the code!
h/t: iphonesdk!

Free CrossOver!

Well, this is just the funniest darn thing I’ve seen in the software industry in, well, ever, actually. CodeWeavers has made their CrossOver [Games] { Mac | Linux } [Pro] products available completely free, for the duration of today, that’s Tuesday October 28. And why, you ask bemusedly? Check the press release:

SAINT PAUL, Minn. (October 27, 2008) – The catastrophic cratering of the global economy, falling gas prices and President George W. Bush’s recent executive activities have indirectly prompted Saint Paul gadfly software developers CodeWeavers, Inc., to provide free software for every American on Oct. 28, company officials reluctantly announced today.

In July, CodeWeavers – whose software lets Mac OS X and Linux users run Windows programs without having to Microsoft for a Windows OS license – launched the Great American Lame Duck Presidential Challenge ( to encourage President Bush to make the most of his remaining days in office by accomplishing a major economic or political goal by January 20, 2009.

The goals focused on President Bush making specific positive accomplishments in areas such as the economy, home values, the stock market, the war on terror and other key issues. Specifically, one goal called for President Bush to help down bring average gasoline prices in the Twin Cities to $2.79 a gallon.

On Monday, Oct. 14, gas prices in Minneapolis and St. Paul did just that.

“That morning, I was filling my tank at Big Steve’s Gas Palace in St. Paul,” said Jeremy White, president and CEO of CodeWeavers. “I had just finished my morning corn dog and 64-ounce Dr. Pepper when I looked at the pump and noticed gas was at $2.79. I screamed ‘Woohoo,’ then I yelled ‘Oh, crap!’ as I realized every American can now have my software for free. Kind of upsets my fourth quarter revenue projections…”

White admits this is not how he foresaw the Challenge unfolding.

“I launched the campaign to inspire President Bush to make the most of his final days in office. Who knew that our Challenge would have this kind of impact on the country?” White said. “On the other hand, who knew that the economy would implode, causing oil demand to drop into the abyss and gas prices to plummet as well. Clearly, investigating Bear Stearns, AIG and those guys is misplaced – CodeWeavers is responsible for this mess. So it’s free software for all!”

That’s just too many kinds of awesome to even start listing. I’ll just let him speak some more.

My fellow Americans. As you probably know by now, we recently succeeded in reaching one of our Lame Duck Presidential Challenge Goals . Of course, we reached it in perhaps the worst way possible–by destroying the world economy. And while ostensibly President Bush was to get the credit/blame for meeting our goals, the bottom line is that I cannot help but feel personally responsible for the greatest financial collapse since the 1930s.

How was I to know that President Bush would take my challenge so seriously? And, give the man credit, I didn’t think there was *any* way he could pull it off. But engineering a total market meltdown – wow – that was pure genius. I clearly underestimated the man.

I’m ashamed that I goaded him into this and take full responsibility for the collapse of any savings you might have. Please accept our free software as my way of apologizing for the global calamity we now find ourselves embroiled in.

h/t: Slashdot!


Sample Code: RSS Reader

Here’s a little tutorial of possible utility; how to build an RSS reader for the iPhone!

Whilst that is a pretty straightforward thing to do, this is a little interesting in that it demonstrates the use of NSXMLParser, flying in the face of what appears to be conventional wisdom that one should rely on the cross-platform libxml2 for their XML-parsing iPhone development projects. And people have gone to some work to make that easier with the TouchXML library which, in case we didn’t mention it in our earlier report, is part of the ever more useful touchcode repository over at Google Code.

‘Course, either of the above — or for that matter, anything at all — are probably better than the last time we had to get into that XML parsing thing a lot, which was struggling to make Xerces work in a large cross-platform source base. There were some very … interesting … issues trying to get wchar-based Windows twaddle and OS X style (also known as the “correct” or “real”, type) of characters to work together. Yeeesh. Well out of that, we are!


Unity for iPhone

Just a quick note today that the Unity game development platform is now shipping an iPhone version.

Personally, we just find it hard to get worked up about these kinds of environments, since they always seem to turn out to not quite allow what you actually want to do; but hey, at least the option’s open for us now!


Bar coding followup

Couple followups for you on our post yesterday about resources for bar code parsing on the iPhone:

First off, web guru extraordinaire Leif Jason points out that the macro vision problem with one’s iPhone has, in fact, been solved!

Slide the Clarifi lens into place over the built-in lens of your iPhone. Your macro and close-up shots are instantly finer in detail, more accurate in color. With Clarifi’s lens, your iPhone can image an entire business card with astounding clarity. Slide the lens aside for normal photography. WIthout Clarifi, iPhone requires about 18 inches to focus properly. Slide Clarifi’s lens into place and you can move in to 4 inches for crisp detail and great pictures.

A useful accessory, indeed. Buy yours now!

Next, another code tip from authoress Erica Sadun — yes, that’s twice in a week, which is probably a good indication that we should get around to checking out her well-received iPhone Developer’s Cookbook Real Soon Now — a treatise on how to do full screen image preview and grab the image directly.

I’m not big on the whole Image Picker Camera interface. I hate how slow it is and how it prevents you from scraping the screen. So here’s my work around. In the following code, I scan down the UIImagePicker presentation to find my way to the actual preview window.

First, I build my camera controller…

Next, I add a delayed call to tell the image picker to update itself. This allows time for the image picker to load before I start messing with its views…

The update adds a bar button item to the navigation bar and removes the overlay leaving just the preview displayed…

This allows me to snap a copy of the screen as desired. 

This would make the process of providing images to your recognition code much more conveniently straightforward to the user than relying on conventional APIs for taking individual images; and it fits much better with the workflow of actually scanning something to have a full screen preview that goes away by itself when a usable image is found.

There you go — we’ve sorted out ways to address pretty much all the obvious roadblocks to putting together a bar code reading iPhone application. Now, anybody have any good ideas what to do with one?


Bar coding

So this iPhone walks into a bar … no, wait, it takes a picture of a bar code. And then it proceeds to do something clever with it. That’s a fairly interesting application space, yes? Well, here’s a roundup of resources to help you along with that!

First off, there’s the Zebra Crossing project at Google Code:

ZXing (pronounced “zebra crossing”) is an open-source, multi-format 1D/2D barcode image processing library implemented in Java. Our focus is on using the built-in camera on mobile phones to photograph and decode barcodes on the device, without communicating with a server. We currently have production-quality support for:

  • UPC-A and UPC-E
  • EAN-8 and EAN-13
  • Code 39
  • Code 128
  • QR Code

We also have experimental support for the DataMatrix format.

Unfortunately, it’s written in Java; however, they do have an iPhone client off the ground, currently supporting QR Code, so there’s something to work with there at least.

Another option is to work from the desktop downwards; the great folks at Bruji who do a variety of ThingPedia applications have freed the source to their barcode scanning engine:

The barcode scanner project, written in Cocoa, is for scanning barcodes on books, DVDs, CDs and video games as well as most other kind of EAN or UPC barcodes. It is part of our programs – DVDpedia, Bookpedia, CDpedia and Gamepedia – and is also used by Books. The code is available for free in the hopes that it’ll be useful to other Mac developers.

And they even offer a $500 bounty if you can improve the code!

Before you get too excited with the possibilities here though, we should note that there is a body of opinion which holds that the optical properties of the iPhone camera will make it challenging to reliably decode ISBN or other 1-dimensional bar codes due to their small feature size, at least unless you attach some kind of macro lens. But hey, if it was easy, anybody could do it, right?:

h/t: iphonesdk!


There is a commercially licensed SDK available at – “Impossibly accurate barcode scanning”!

And another called VSBarcodeReader – “the most advanced barcode reading library for the iPhone”!

Note this Stack Overflow thread on their pricing:

… Red Laser is expensive though. They ask 10% of your sales of which an upfront fee of $2500…

… I wanted to user VSBarcodeReader, but Vision Smarts quoted me a price of $7000 USD and 10% of my sale price…

Another somewhat cheaper commercial option is Softek Barcode Reader Toolkit SDK.

And there is a free – but including ads – SDK available at

And there’s the Barcode iPhone App project using the open source libdmtx.available on Google Code.

If QR Codes are good enough, check out Open Source QR Code Library; there’s a project using it here, and another here.

Or for QR Code and ECN/ISBN, there’s Zbar on Sourceforge.


For creating barcodes, as opposed to scanning them, check the free iOS Barcode Library!


Some cool real world + iPhone barcode integration ideas here:

The iPhone as Barcode Scanner: A Huge Opportunity


Scraping your reviews

So, I’m sure you’ve all been there with us on your first iPhone app: Soon as it’s up there you want to see ALL the reviews! Right NOW! NOW NOW NOW! But iTunes only lets you see the reviews for the country you have an account in, bah! So how do you get around this conundrum? Well, you could make friends with people with iTunes accounts in the other 61-odd countries, I suppose; or, you could simply apply this script from voluminous authoress Erica Sadun:

As you know, iTunes currently exists in 60-odd countries. 62 if I’ve done my counting right. Each store has its own storefront code, which I have laboriously produced for you below. Seriously, this took forever! These country codes allow you to access AppStore for each country and retrieve the review data you’re looking for…

The user review URL shown here returns the first page of the most recent (sortOrdering=2) reviews. You can retrieve those reviews directly from the Terminal command-line.

To talk to iTunes from curl, spoof the user agent to pretend to be iTunes and set your store front to one of the legal values. Here, I set the store by passing it as a header field using curl’s -H switch…

The last step involves looping this over all available stores. It’s easy to throw together a perl script that does exactly that, opening the results in TextEdit. The source for that script follows at the bottom of this post.

Incredibly useful, no? But it gets better! Another fellow Jeremy Wohl took this and ran with it to fix various issues and call Google Translate as well, you can find that hosted on github here; and for the absolute ultimate in convenience, yet another fellow John Ballinger has written that into a Dashboard widget. Really couldn’t ask for anything more, could you?


iWebKit 3.0

Here’s a note for all of you doing iPhone-friendly websites: iWebKit, a nifty collection of Mobile Safari goodies for doing Apple-style iPhone-friendly web pages is now updated to version 3.0.

- New music list
- New item list
- New item list with images
- slide effect as a plugin
- Blue buttons on touch/click
- bug fixes (example: having no space at the bottom of a textbox)
- rebuilt topbar image so it doesnt “dive under” the navigation bar in safari
- added the removal of the url bar and image preload in the download pack
- fixes a bug where the url bar would go up 1px too much
- visual fixes
- removed the <li class=”break”> tag since it was not used well
- worked on the computer site (like the integration section)
- rebuilt to be more reflective of iwebkit’s power.
-some minor changes in the overall code

Looks good, works well, free to use. What more could the aspiring mobile webmonkey ask for?

h/t: BraveNewCode!


More Core Animation

As a companion to yesterday’s post, here’s another Core Animation + iPhone snippet: 3D Transformations on iPhone with Core Animation!

Apart from getting all my existing CA examples onto the iPhone I’ve also been toying with what the best way to build out the ‘photo city’ demo from WWDC 2008 would be (my next Core Animation screen cast series). The basic idea of the demo was that you had a set of perhaps 30 or 40 images, the images were combined into cubes and the cubes were used to make a ‘city’. After getting a basic cube working I got distracted by some of the stuff I did to make the demo. Namely I finally got around to porting the OpenGL trackball example code to Core Animation.

For those that are not familiar with the trackball example; the idea is that you have a transparent sphere around your scene, you can move the scene around by moving the trackball. As you move your finger to the right it pushed this imaginary sphere around its center to the right (exposing the left side of the scene).

Make sure to follow the “existing” link above for general Core Animation stuff as well as the trackball controller talked about in that article. Nifty stuff, this Core Animation, yes indeedy!


Sample code: Desk Jockey

Here’s a nice little project for you to dig around in if you’ve been checking out the snazzy stuff you can do with Core Animation – heck, you even bought the book — and been meaning to get into it seriously Real Soon Now. Not that we know anybody like that of course, but just in case you do, have them check this piece from Benjamin Ragheb out, called Desk Jockey:

On October 8, 2008 I gave a presentation at the New York City iPhone Developer Meetup on using Core Animation to design games. Specifically, the talk was focused on creating a scene using CALayer and then responding to touch events so that certain layers can be dragged around the screen.

Download (3.2 MB) the Xcode project and slides.

For your trouble you’ll get a reasonably clearly written exposition of how to mix Core Animation with interactivity on the iPhone, along with a sample project demonstrating it in action:

Pretty cool stuff, this Core Animation, for not very much code. Definitely worth checking into. And if you do, a nice gesture to show appreciation would be to buy Benjamin’s programs FatWatchicon and Ruboku
icon, we definitely want to support people who share the knowledge, don’t we?

h/t: iphonedev!