具有另一种通用类型

时间:2016-11-03 14:59:05

标签: ios swift xcode

我正在努力解决以下问题。

我有一个名为FilteredCollection的类,它有两个通用参数。

  • CollectionSourceModel
  • CollectionFilterObject

CollectionFilterObject还需要一个等于CollectionSourceModel的通用参数。这看起来像以下代码段:

class FilteredCollection
    <
        CollectionSourceModel: CollectionItem,
        CollectionFilterObject: CollectionFilter<CollectionSourceModel>
    >:
    Collection<CollectionSourceModel>,
    CollectionFilterDelegate
 {
      let filterHandler: CollectionFilterObject
 }

并允许我创建如下的子类:

class TheatreFilter: CollectionFilter<TheatreItem>
{
     // some filter stuff
}

class TheatreCollection: FilteredCollection<TheatreItem, TheatreFilter>
{
     // some collection operations
}

这不会在代码中显示错误,但会给我留下编译错误:

Command failed due to signal: Segmentation fault: 11

我的模式是否有更好的解决方法?

0 个答案:

没有答案