objective-c - Objective C 泛型 - 条件编译

标签 objective-c xcode generics c-preprocessor xcode7

编写在使用 Xcode 7 编译时利用泛型但也可以在 Xcode 6 上编译的代码的最简单方法是什么?

我猜想某种预处理器技巧可以完成这项工作,也许是这样的:

#define XCODE7_ONLY(x) ...

NSDictionary XCODE7_ONLY(<NSString*, NSString*>)* dictionary;

最佳答案

您可以使用 __has_feature(objc_generics) 宏来测试 Obj-C 泛型。所以你可能想试试:

#if __has_feature(objc_generics)
#define XCODE7_ONLY(...) __VA_ARGS__
#else
#define XCODE7_ONLY(...)
#endif

关于objective-c - Objective C 泛型 - 条件编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32246652/

相关文章:

generics - 为什么 C# 无法隐式转换 Action<T>Where T : BaseType to Action<BaseType>

java - "Unchecked generic array creation for varargs parameter of type Matcher <? extends String> []"警告使用 CoreMatchers.allOf()

java - 使用下限通配符时出现编译错误

ios - 如何以编程方式显示具有 Storyboard 中定义的导航 Controller 和标签栏 Controller 的 Controller ?

iphone - 由于苹果链接器错误,单元测试在应用程序重命名后无法运行

objective-c - 如何从 CGContextRef 获取 UIImage?

Xcode Build and Archive 不会保存 ipa 文件

ios - AVQueuePlayer 设置音频的 Tempo

xcode - iOS应用程序中确实需要MainWindow.xib吗?

ios - UIApplicationDidBecomeActiveNotification 和 UIApplicationWillResignActiveNotification 并不总是在 Unity iOS App 中触发