Thursday, September 7, 2017

Can you use Deprecated Functions?

Hey guys, I am making a few tutorials but all are in progress right now. Hope to publish them this weekend. Anyways, as a frequent StackOverflow visitor, I often read programmers wanting to change the functions they used that are deprecated. From their postings, I get that many programmers think that deprecated means "cut off" and therefore cannot be used indefinitely. This is, false.

Let us take a look at the meaning of the word first.


Basically, it means disapproved (or in layman terms, not advised to be used). It is not the same as totally cannot be used in which case the word is BANNED. Deprecated is not banned. It is only advisable not to use the function. BUT YOU CAN STILL USE IT.

In iOS developer terms, you can surely use a deprecated function, but you must start thinking/planning/coding of the new function to replace it in 4-5 years time. Deprecated functions normally are supported for a long time before they are removed. This is because often, Apple creates new and better frameworks for a thing. But there will be many apps that rely on that framework that are already in the App Store. So to immediately ban a function, is an act of oppression.

For example, NSURLConnection. It was introduced in iOS2.0. It's successor, the NSURLSession was introduced in iOS7.0. So since iOS7.0, NSURLConnection is therefore flagged as deprecated. But can you still use it in iOS10? YES IT STILL WORKS. In iOS11? Nobody knows (except the beta users right now). Given 3 versions of iOS has passed, you oughta change it by now.

But if it was *just* deprecated in iOS9 for example, no sweat because that function will definitely be available even in iOS11. So if you're doing a quick update of your apps, very old functions that are deprecated (like the ones intro'd in iOS2.0), should be replaced. But if the deprecation appear in iOS8 or 9, you're likely safe to leave it as it is for now.

Hope this post has been beneficial. Happy coding!