Objective-C泛型
Lightweight generics now allow you to specify type information for collection classes such as NSArray, NSSet, and NSDictionary. The type information improves Swift access when you bridge from Objective-C, and simplifies the code you have to write. For example:
- 翻译:OC当中引入轻量级泛型,现在允许您为 NSArray、NSSet 和 NSDictionary 等集合类指定类型信息。当您从 Objective-C 桥接时,类型信息改进了 Swift 访问,并简化了您必须编写的代码。
- 关键字:
@interface NSArray<__covariant ObjectType> : NSObject <NSCopying, NSMutableCopying, NSSecureCoding, NSFastEnumeration>
<__covariant ObjectType> 实现了OC中的泛型功能。其中,ObjectType是Objective-C中的泛型
|