使用2个依赖泛型类型声明swift类

时间:2016-12-07 11:37:08

标签: swift xcode swift3

我有一个模型,它看起来像这样:

  • 比赛 - 比赛名单
  • 比赛 - 名单项目

我还要创建大量此类列表并将它们显示在单独的ViewControllers中。

class Competition : ServerConfiguredObject {

    var caption = ""

    override func confirure(_ response: DictionaryWithStringKeys) {
        caption = response["caption"] as! String
    }
}

class Competitions : ServerConfiguredObjectsStorage <Competition> {

}

我的目标是像这样声明viewController:

    typealias CompetitionsViewController = ServerConfiguredObjectsViewController <Competition, Competitions>

所以我已经声明了View控制器并将集合类集合项类添加到模板中。而且我有一个错误。

First efford:

class ServerConfiguredObjectsViewController 
     <ServerConfiguredObjectsStorageClass:
         ServerConfiguredObjectsStorage<ServerConfiguredObjectClass:ServerConfiguredObject>> : UIViewController

编译错误(突出显示类声明的字符串):

MyClassFullPath.swift:11:141:预期&#39;&gt;&#39;完成通用参数列表

第二个efford:

class ServerConfiguredObjectsViewController 
    <ServerConfiguredObjectClass:ServerConfiguredObject, 
     ServerConfiguredObjectsStorageClass: 
         ServerConfiguredObjectsStorage<ServerConfiguredObjectClass>> : UIViewController

Swift编译器错误(类声明的字符串未突出显示):

命令/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc失败,退出代码为1

您怎么看?在第二种情况下它是一个快速的BUG吗?(我认为swift必须至少突出声明字符串。)

PS

我能理解为什么它不起作用。但我的目标是让它有效。我会感谢任何建议。

无论如何,感谢您的关注。

1 个答案:

答案 0 :(得分:1)

你的问题的第一部分很容易回答:swift编译器不应该只是崩溃,无论你抛出什么艺术。向Apple提交错误报告。