Archive for November, 2008


iPhone site design

If you’re involved in writing web pages for the iPhone, here’s some thoughts from people who learned their lessons putting together an interface for a pretty popular site:

A few weeks ago we released a version of the Flickr site tailored specifically for the iPhone. Developing this site was very different from any other project I’ve worked on; there seems to be a new set of frontend rules for developing high-end mobile sites. A lot of the current best practices get thrown out the window in the quest for minimum page weight and fastest load times over slow cellular connections.

Here are a few of the lessons we learned (sometimes painfully) while developing this site…

Good tips on both UI design and technical limits. Read and learn!


Snippet: Pinch And Stretch

Here’s some sample code provided by Erica Sadun via Apple on the iphone-sdk list that was worked up to do the job of updating gesture-driven transformations on the fly. If you’ve struggled with doing this kind of thing so as to make the consequences work out intuitively — and if you haven’t, it’s not quite as straightforward as you think! — there’s probably some good tips for you to be found picking through this. Enjoy!

Continue reading ‘Snippet: Pinch And Stretch’



So all of you out there you program Macs or iPhones no doubt know the keen pain of going to BugReporter, painstakingly spending great effort to document your problem as exhaustively and helpfully as humanly possible, and then getting back something along the lines of

31-Jul-2008 05:51 PM Stoney Gamble: This bug has been closed as Duplicate. We are aware of and tracking this issue under the Bug ID listed above in the bug State (Duplicate/XXXX). To check the status of the original bug report, please send an email to [email protected] referencing your Bug ID.

and being understandably all steamed up over not only wasting your own time, but having had no way to find out that this was a known problem before however many hours it was you spent coming to the conclusion that no, you actually were doing absolutely everything right, and it really was Apple’s fault that it wasn’t working.


Well, now somebody‘s done something about it! Meet OpenRadar, a place for community-minded developers to share their Radar bugs for the greater enlightment of all:

This weekend Dave Dribin suggested on Twitter that he’d like to build
an open database of Radars, something like a wiki that we could use as
a community-fed opt-in system. After exchanging some messages with
Dave and Joachim Bengtsson, I put together a simple demo app on Google
App Engine:

It’s basic but enough to get us started. I’ve put the code on github,
and I am completely open to suggestion about this. If you think it’s
valuable, please start using it and we’ll add whatever missing
features we need.

Also, to make it easy to get data out of this, there’s an api that   
you can use to get a JSON dump of the entire store:

That will be good until we get up to 1000 radars.

If you have comments or ideas, please add them to the openradar wiki
on github:

A most worthy endeavour indeed, which all Radar users should support. And interesting browsing material to boot!

h/t: iphonesdk!



Today we have for you an intriguing new option for providing location services in your OS X and iPhone applications; Microsoft Virtual Earth, of all things, by way of the eponymous VirtualEarthKit. From the author:

I’ve been working with Microsoft recently in bringing their Virtual Earth services to the Mac and iPhone. The result is VirtualEarthKit, a BSD licensed Cocoa framework, managed completely independently of Microsoft. VirtualEarthKit provides several services to Mac and iPhone programmers, such as geocoding (place name/address -> latitude/longitude), international reverse geocode (latitude/longitude -> place name), static maps, and fetching of individual map tiles. Later releases will include yellow pages searching, and turn by turn route guidance.

Whew! That’s a pretty long list already, yes? But wait, it gets even better!

In addition, I’m also working on a fully native OpenGL based map view for both Mac OS X and the iPhone. The iPhone map view is already working and shipping in a iPhone product, but is awaiting some cleanup before it’s added to the svn archive.

Now is that awesome, or what? You can see a screenshot of what I presume is the referred to map view in this post on Microsoft’s Virtual Earth blog.

Now, the next question is exactly what kind of terms are involved in using this, of course. Details on that are a little sparse, unfortunately. About all we’re given is

Use of VirtualEarthKit requires an account with Microsoft. Use of VirtualEarthKit in a shipping application (without watermarks) requires a contract with Microsoft.

Hmmm. Well, let’s leave aside just what implications those contract terms might have for actually marketing an application, just having this available at all is a great step forward. So if this all sounds like just the kind of thing you’ve been waiting for to create The Ultimate Mapping Application, the VirtualEarthKit code is here, a tutorial is here, and signing up for your Virtual Earth development account starts here. Enjoy!

h/t: cocoa-dev!


Tip: Porting Core Audio

Here is your tip of the day for porting Core Audio code from the desktop:

Look for the ::AudioUnitSetProperty() call which sets the HAL-feeding callback. If your desktop source is of Core Audio version 1 vintage, it will be using the constant


which still works perfectly in desktop code as of the Leopard SDK. Intriguingly, it will also compile perfectly fine with the iPhone 2.1 SDK — and produce no runtime error either. However, it will not work, leaving you utterly baffled as to just why on earth your perfectly good callback is never getting called back.

The solution is to change that constant to the newly correct


and then everything will play just fine. 

A quick Google search shows me that the older constant is found, for instance, in lots of searchable archives of Simple DirectMedia Layer library code, SDL_coreaudio.c to be exact. So if you’re trying to port some libSDL-using project to the iPhone and wondering why your error-freely compiling and running code isn’t @#($&@!!! playing a @(#$^!!! thing … hey, check that out for starters!


Snippet: Phone number

Quick one liner for you today: Ever wondered how to retrieve the user’s phone number programmatically? Well, here’s the trick:

   id number = [[NSUserDefaults standardUserDefaults] objectForKey:@”SBFormattedPhoneNumber”];

   NSLog(@”user phone number is %@”, number);

Run that and you’ll get output like
user phone number is 1 (555) 555-5555

Beats the heck out of asking the user to select their own address book entry or something like that, doesn’t it now?

h/t: iphonesdk!


Tip: Debugging exceptions

Don’t you just hate it when you finally get your program linking, you run it, and instead of seeing your glorious code executing away you get something like this?

2008-11-13 21:12:25.866 Play MPE[1369:20b] * -[PMPELoginViewController loginSucceeded:]: unrecognized selector sent to instance 0x40d560

2008-11-13 21:12:25.867 Play MPE[1369:20b] * Terminating app due to uncaught exception

Most annoying, that. So what can you do to catch that kind of nonsense in the act? Or other runtime failures?

Well, the Breakpoints window in Xcode (Run > Show > Breakpoints) is your friend. Simply add these project or global breakpoints:


+[NSException raise:format:]




and then hey presto, the debugger comes up stopped on the source line, in this case

[self loginSucceeded:loginResultData];

Much easier to debug, that!

[EDIT: And here's some others you might try as well:




h/t: iphonesdk



Real users

Here’s an interesting presentation on some findings from studies of actual people using an iPhone on some principles to guide your user design.

We frequently see that interaction and visual designs from one flagship product – such as the iPhone – have an influence throughout design for the web, desktop, mobile, and consumer electronics platforms. As a strategic design firm, Create with Context finds it important to stay on top of emerging design trends. 

We recently published “How people really use the iPhone”, an interesting readout of design issues and recommendations for people designing for the iPhone and beyond. Our presentation on this topic at the iPhone Developer’s Summit was called the “best presentation of the conference” by several attendees.

If you’d prefer a PDF of the presentation, you can download it from here.

h/t: iphonesdk!


Cornerstone 1.1

News from the tools front: The Greatest SCM Client EVAR, Zennaware Cornerstone, is now up to version 1.1 with a whole big whack of fixes and new features. If you weren’t convinced by my reasoning for deciding to buy version 1.0, then take a look at the much more detailed review that Jade Ohlhauser has done here — but here’s the money quote:

In my first comparison I could see the advantages that Cornerstone had to offer, but it had flaws in the workflow I needed every day. Now that those flaws have been addressed, the comparison isn’t even close. I’m going with Cornerstone. Something we can all agree on is that the competition benefits everyone. Subjectively speaking, however, it seems to me that the Cornerstone developers have made more progress in the last 4 months than the Versions team has.

As an example of that progress, let us look at a recent exchange I had with the Cornerstone author, when I got mildly annoyed at the array of projects I wasn’t actively working on at the moment taking a while to update. Note the date and time on the email I sent –

Date: October 25, 2008 6:20:13 AM PDT (CA) Subject: Support Request Is there any way to turn off the working copy refresh on an individual basis instead of globally? If there isn’t, could I please put that in as a feature request? …

– and check out how long getting it sorted took.

Date: October 25, 2008 11:15:07 AM PDT (CA) Subject: Re: Support Request Hi Alex, I have implemented per-working copy refresh configuration for 1.1 which is currently at the release candidate stage and will be released in the next two weeks.Best regards,

Now you just can’t beat service like that. If you’re using Subversion, you owe it to yourself to get Cornerstone and make life easier on yourself!


Snippet: Recognizing Shakes

Here’s a couple tips for you on using accelerometer:didAccelerate data to recognize a shake of the device, which has to be the most awesome method of user input ever.

First off, from the redoutable Erica Sadun:

I personally took the dot product as such:

float dot = (px * xx) + (py * yy) + (pz * zz);
float a = ABS(sqrt(px * px + py * py + pz * pz));
float b = ABS(sqrt(xx * xx + yy * yy + zz * zz));
dot /= (a * b);

Where px is the previous x acceleration and xx is the current, etc, 
looking for a value less than zero.

As an alternative, you can find a complete implementation here of shake detect code that was used in the DiceShaker application you can download for free to see how it works, along with comments and other pointers.

Because, as we all know, it’s always awesome when you can Shake That

h/t: iphonesdk!