views:

237

answers:

2

For example, suppose I had written my own class which allowed me to record audio on the iPhone. iPhone OS 3.0 now provides that functionality as a part of the Cocoa Touch Framework.

How can I use my existing class to support iPhone OS version 2.2.1 and earlier, but at the same time take advantage of the new class provided by the Cocoa Touch Framework to support iPhone OS 3.0?

+4  A: 

The iPhone platform has the highest upgrade rate of any mobile OS so I would not get worried about backward compatibility. Move to the OS 3.0 API and focus on doing more other great stuff with your app.

If people want your app and they have 2.2.1 - all they have to do is upgrade - and iPhone OS is also the easiest OS to upgrade.

Grouchal
Except if you have an iPod. Every upgrade has costed iPod users $10, adding up to $30 so far.
Will Eddins
Guard makes a good point. The $10 definitely slows down the iPod Touch crowd. I think there's a good portion of the iPod users that will never upgrade. Luckily, it's the same group that will never buy apps! Within a few weeks, I think most of the top apps on the store will require 3.0 - so I wouldn't worry about compatibility.
Ben Gotow
Signs point to high adoption, even for iPod Touch users: http://tapbots.com/blog/news/iphone-os-30-adoption-rate
Hunter
Yes, but that article is slightly biased due to the fact they limited their survey to only the users who were running the latest version of ConvertBot (which weeds out the people who don't update much)
mclaughlinj
+4  A: 

Since Objective-C is a very dynamic language, you can target 2.x and query for the existence of 3.0 features:

id pasteboard = [objc_getClass("UIPasteboard") generalPasteboard];
if (pasteboard) {
    NSLog(@"Got pasteboard, we're clearly on 3.0+");
} else {
    NSLog(@"Pasteboard not available, definitely 2.x");
}
rpetrich
This is great and shows one of the many ways you can determine what version of the OS you're running and run different code depending on that conclusion.
mclaughlinj
This is more along the lines of what I had in mind. However, is there any way to directly query to OS version? Tying the determination of the OS version to the existence of specific features feels brittle to me.
Jonathan Arbogast