Swift generic superclass' init not accessible when constructing its subclass

前端 未结 4 2081
春和景丽
春和景丽 2021-01-01 18:48

I have the following codes:

class ILProperty {
    var value: T?
    init(_ value: T) {
        self.value = value
    }
}

typealias ILStringProper         


        
4条回答
  •  悲&欢浪女
    2021-01-01 19:43

    As ganzogo mentioned it seems to be working fine with the latest Swift (3.0). Also, why do you declare a separate class to assign to the typealias? I've tried this in a Playground and it seems ok:

    class ILProperty {
        var value: T?
        init(_ value: T) {
            self.value = value
        }
    }
    
    typealias ILStringProperty = ILProperty
    let x = ILStringProperty("X")
    

提交回复
热议问题