Swift 4:协议如何定义子类类型

时间:2017-10-27 03:23:15

标签: swift protocols

我有协议定义一个函数return self

public protocol DBObject {
   static func select(where condition:String?) -> Array<DBObject>?
}

然后购买符合DBObject

public struct Shop:DBObject {

}


guard let array = Shop.select(where:nil) else{
      return
}
for shop in array {
  let _ = shop as! Shop
}

我知道array总是返回Array<Shop>,但我不知道如何定义类似子类

像那样:

static func select(where condition:String?) -> Array<conform.Type>?//Is there such a way?

怎么办?

0 个答案:

没有答案