问题描述:

I'd like to have something like:

@property (nonatomic, nonnull, copy) NSArray <Route *> *routes;

But I need to support older builds of Xcode. With designated initialisers it was possible to do a lookup in the compiler to see if it was supported via:

#if __has_attribute(objc_designated_initializer)

I did some digging but couldn't find where these were defined, as I imagine that somewhere there is one for lightweight generics .

网友答案:

I found it within https://gist.github.com/smileyborg/d513754bc1cf41678054

#if __has_feature(objc_generics)
#   define __GENERICS(class, ...)      class<__VA_ARGS__>
#   define __GENERICS_TYPE(type)       type
#else
#   define __GENERICS(class, ...)      class
#   define __GENERICS_TYPE(type)       id
#endif
相关阅读:
Top