问题描述
如果我在iOS项目中包括仅在(例如)iOS 9中可用的框架,但我仍在支持iOS 8,如何根据iOS版本有条件地遵守委托协议?例如,我知道我可以有条件地包括这样的框架:
If I am including frameworks in my iOS project that are only available in (for example) iOS 9, but I am still supporting iOS 8, how do I conditionally conform to a delegate protocol depending on the iOS version? For example, I understand I can include the framework conditionally like this:
#import <Availability.h>
#ifdef __IPHONE_9_0
#import <Something/Something.h>
#endif
但是,如果该框架也需要符合委托协议怎么办?
But what if that framework also needs to conform to a delegate protocol?
@interface ExampleController()< UITextViewDelegate,SomethingDelegate>
如果我在iOS 9上,如何仅包含"SomethingDelegate"?
How do I only include "SomethingDelegate" if I'm on iOS 9?
谢谢!
推荐答案
嗯,大致相同:
@interface ExampleController () <UITextViewDelegate
#ifdef __IPHONE_9_0
, SomethingDelegate
#endif
>
顺便说一句,这不是您应该检查设备是否正在运行iOS 9的方式-.
By the way, this is not the way you should check if the device is running iOS 9 - this only checks if your Xcode supports iOS 9.
这篇关于如何有条件地遵守委托协议?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!