logo
  • 教程列表
  • SO官方文档
  • 类和对象
    • 分配和初始化之间的区别
    • 使用初始化值创建类
    • 单例类
    • instancetype 返回类型
    • 指定泛型
  1. StackOverflow 文档
  2. Objective-C Language 教程
  3. 类和对象
  4. 指定泛型

指定泛型

Created: November-22, 2018

你可以像 NSArray 或 NSDictionary 一样使用泛型增强自己的类。

@interface MyClass<__covariant T>

@property (nonnull, nonatomic, strong, readonly) NSArray<T>* allObjects;

- (void) addObject:(nonnull T)obj;

@end
  • instancetype 返回类型

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 关于我们
  • 免责声明