Foundation 和 UIKit 的弱链接?
我最近介绍了通过 AirPrint 进行打印,但不想放弃对 4.2 之前版本的支持(显然)。之前做过类似游戏中心等的事情。我发现在这种情况下特别奇怪的是我必须弱链接 UIKit。打印不包含在它自己的框架中,这让我可以更细化。
尽管它解决了我的问题,允许应用程序在所有版本上正常运行,但这感觉不太对劲。
在 Apple 的 SDK 兼容性指南中,他们状态:
当使用的框架是 在您的部署目标中可用, 你应该需要那个框架(并且 不是弱链接它)。
UIKit是可用的,只是UIPrintInfo
、UIPrintInteractionController
等类不可用。
我说得对吗,弱链接这样一个核心框架似乎很奇怪?有更好的办法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个更好的方法。 iOS 4.2 为此引入了 NS_CLASS_AVAILABLE,但使用它有一些限制。所有详细信息都列在下面链接的文档中:
http://developer.apple.com/library/ios/#documentation/DeveloperTools/Conceptual/cross_development/Using/using.html
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