Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weak Linking Foundation and UIKit?

I introduced Printing via AirPrint recently, but wanted to not drop support for pre 4.2 versions (obviously). Done it before for things like Game Center, etc. What I found particularly odd in this case was I had to weak link UIKit. Printing was not contained in its own framework allowing me to be more granular.

This just didn't feel right, although it solves my problem allowing the app to run properly on all versions.

In Apple's SDK Compatibility Guide they state:

When using a framework that is available in your deployment target, you should require that framework (and not weakly link it).

UIKit is available, just not classes such as UIPrintInfo, UIPrintInteractionController, etc.

Am I right that it seems odd to weakly link such a core framework? Is there a better way?

like image 277
MarkPowell Avatar asked Jan 06 '11 14:01

MarkPowell


1 Answers

There is a better way. iOS 4.2 introduced NS_CLASS_AVAILABLE for this purpose, but there are some restrictions on using it. All the details are listed in the documentation linked to below:

http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/cross_development/Using/using.html

like image 65
Steven Kramer Avatar answered Oct 13 '22 20:10

Steven Kramer