What is the Best Way to Use iPhone 3.0 Features While Still Maintaining Compatibility with Earlier Versions?

StackOverflow https://stackoverflow.com/questions/1034348

  •  06-07-2019
  •  | 
  •  

Question

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?

Was it helpful?

Solution

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");
}

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top