我刚刚从2015 WWDC示例代码(
https://developer.apple.com/sample-code/wwdc/2015/)下载了FourInARow,并注意到文件AAPLViewController.m中有一个奇怪的属性声明
@property NSArray<NSMutableArray<CAShapeLayer *> *> *chipLayers;
这是什么意思?
解决方法
它是Objective-C的新成员,名为
Lightweight Generics.它是在iOS9 / OS X 10.11中引入的,目的是增强Swift和Objective-C之间的互操作性.正如文件所说:
Objective-C declarations of NSArray,NSSet and NSDictionary types
using lightweight generic parameterization are imported by Swift with
information about the type of their contents preserved.For example,consider the following Objective-C property declarations:
@property NSArray<NSDate *>* dates; @property NSSet<NSString *>* words; @property NSDictionary<KeyType: NSURL *,NSData *>* cachedData;
Here’s how Swift imports them:
var dates: [NSDate] var words: Set<String> var cachedData: [NSURL: NSData]
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。