代码之家  ›  专栏  ›  技术社区  ›  Renetik

在swift类中扩展通用目标c类

  •  2
  • Renetik  · 技术社区  · 6 年前

    因此,我正在慢慢地向代码库添加更多swift文件。

    ListData<Type : CSJSONData *> : ServerData <CSListData>
    

    我想在swift类中将其子类化如下:

    @objc class ArticlesData: ListData<Article> 
    

    编译器给了我一个错误:

    Generic subclasses of '@objc' classes cannot have an explicit '@objc' because they are not directly visible from Objective-C
    Replace '@objc ' with ''
    

    1 回复  |  直到 6 年前
        1
  •  3
  •   CRD    6 年前

    从…起 The Swift Programming Language (4.2), Attributes :

    不幸的是,对你来说,这是相当确定的。