Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 620
Jonathan Arbogast Avatar asked Mar 01 '23 14:03

Jonathan Arbogast


1 Answers

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");
}
like image 191
rpetrich Avatar answered May 06 '23 23:05

rpetrich