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?
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");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With