2021年3月28日星期日

Is it possible to fulfil the generic constraint on a Swift (SwiftUI) class in a new init?

While the following example is simple, it fails to compile because Swift cannot determine that the Text() view is the Content type required by the generic constraint (with error "Cannot convert value of type 'Text' to closure result type 'Content'").

Is there any way to have an init that can fulfil the generic constraint?

extension VStack {    init() {      self.init(spacing: 0) {          Text("Test")      }  }  

}

https://stackoverflow.com/questions/66847490/is-it-possible-to-fulfil-the-generic-constraint-on-a-swift-swiftui-class-in-a March 29, 2021 at 08:39AM

没有评论:

发表评论