Hadi Sharghi
Hadi Sharghi

Reputation: 1005

Developing with deprecated frameworks

I have a general question as I found many frameworks are deprecated in iOS 9. Consider developing for iOS 7 and above with the latest Xcode and iOS SDK. I'm going to use UIAlertView which is deprecated in iOS 9 and replaced with UIAlertController. In my code when I want to show an alert, should I have to check for iOS version and provide a block of code using UIAlertView for iOS prior to 9, and another block of code for UIAlertController for iOS 9 and above? The same goes for AddressBook and AddressBookUI frameworks which are replaced with Contacts and ContactsUI frameworks.

I know that many deprecated frameworks still work fine with new iOS SDK but sometime in future there will be a chance of not working fine. What would be a good approach on this issue?

Upvotes: 1

Views: 582

Answers (2)

Desmond
Desmond

Reputation: 787

Check iOS version first is a good way. Besides, you can use respondsToSelector method to check whether the new methods are supported on the (new) running devices.

Upvotes: 1

rmaddy
rmaddy

Reputation: 318804

First off, UIAlertView was deprecated in iOS 8, not iOS 9.

Deprecated doesn't mean removed. It means obsolete.

As long as an API isn't deprecated in your Deployment Target, it should be safe to use. It's very rare for a deprecated API to actually stop working.

Like everything else, test to be sure everything works on each version of iOS your app supports.

When you drop support for iOS 7 in some future update of your app, you can replace all uses of UIAlertView with uses of UIAlertController.

Similar for AddressBook. Keep using it until your Deployment Target becomes iOS 9 then you can migrate to using the new Contacts framework.

Of course if a new API offers functionality that you wish to use on devices that support, feel free to do so. Just make sure you don't try to use newer APIs on devices with older versions of iOS.

Keep this in mind. There are apps that were written in iOS 2.0 seven years ago. Many of these apps still work under iOS 9.

Upvotes: 2

Related Questions