Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use @compatibility_alias to alias classes for previous versions of iOS

Tags:

ios

iphone

Can somebody tell me how to use @compatibility_alias to take a class, for example, UIActivityViewController, that is new to iOS 6, and use @compatibility_alias to make it work on iOS 5 and iOS 4. Please be specific and say where to put the code, and how to use it.

like image 712
jonathan Avatar asked Jan 15 '23 15:01

jonathan


1 Answers

It is just an alias of method names, nothing more.

It is a feature of the Objective-C compiler rather than of the runtime

Looking at NSHipster we see:
@compatibility_alias: Allows existing classes to be aliased by a different name.
This allows one to write their own implementation of a class that is not available in the current SDK and "alias" the name to that of the class in the newer sdk. So, the key is to write or find another class that has the same methods and behaviors of another unavailable class.

There is no magic bullet here.

As an aside: I used to have to stand in line in the Post Office and there was a sign that said: "If it seems to good to be true, it probably is", that applies here.

See NSHipster, search for @compatibility_alias.

like image 177
zaph Avatar answered Jan 21 '23 07:01

zaph