Using Swift protocols with generics

前端 未结 2 621
独厮守ぢ
独厮守ぢ 2020-12-09 14:34

I have a simple example that seems like it should work:

import CoreData

@objc protocol CoreDataModel {
    @optional class func entityName() -> String
}

         


        
2条回答
  •  孤街浪徒
    2020-12-09 14:52

    From "The Swift Programming Language"

    Because T is a placeholder, Swift does not look for an actual type called T.

    As T is not a real type, it is maybe not useful to cast to T.

提交回复
热议问题