What is the best way to take advantage of iPhone 3.0 while maintaining compatibility with earlier versions?

For example, suppose I wrote my own class, which allowed me to record audio on an iPhone. iPhone OS 3.0 now provides this functionality as 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 use the new class provided by Cocoa Touch Framework to support iPhone OS 3.0?

+4
source share
2 answers

Since Objective-C is a very dynamic language, you can configure 2.x and request for 3.0 functions:

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

The iPhone platform has the fastest update rate of any mobile OS, so I would not worry about backward compatibility. Go to API OS 3.0 and focus on doing more other great things with your application.

If people want your application and they have 2.2.1, all they need to do is update - and the iPhone OS is also the easiest OS to update.

+4
source

Source: https://habr.com/ru/post/1286641/


All Articles