本文介绍了包含尖括号<>的奇数属性声明语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我刚从2015 WWDC示例代码下载了FourInARow()并注意到文件中的奇怪属性声明 AAPLViewController.m
I just downloaded FourInARow from 2015 WWDC sample code (https://developer.apple.com/sample-code/wwdc/2015/) and noticed an odd property declaration in file AAPLViewController.m
@property NSArray<NSMutableArray<CAShapeLayer *> *> *chipLayers;
这是什么意思?
推荐答案
这是Objective-C的新增内容,名为。它是在iOS9 / OS X 10.11中引入的,目的是增强Swift和Objective-C之间的互操作性。正如文档所说:
It is a new addition to Objective-C, called Lightweight Generics. It was introduced in iOS9 / OS X 10.11 in order to enhance interoperability between Swift and Objective-C. As the documentation says:
例如,请考虑以下Objective-C属性声明:
For example, consider the following Objective-C property declarations:
@property NSArray<NSDate *>* dates;
@property NSSet<NSString *>* words;
@property NSDictionary<KeyType: NSURL *, NSData *>* cachedData;
var dates: [NSDate]
var words: Set<String>
var cachedData: [NSURL: NSData]
这篇关于包含尖括号<>的奇数属性声明语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!