2021年2月10日星期三

How can I make my CustomView conform to more than one protocol in SwiftUI?

I am working on a CustomView which it must conform 2 protocol to start working, my request protocols are: Hashable and CustomStringConvertible, the issue start where that my CustomView can take one protocol, I tried to feed both but I failed, for sure I am missing something in syntax, need help for correction please.

struct SequencePrinterView<T: Hashable, CustomStringConvertible>: View {        let sequence: Array<T>        init(sequence: Array<T>) {            self.sequence = sequence           }        var body: some View {            ForEach(sequence, id:\.self) { item in                            Text(item.description )                        }          }    }  
https://stackoverflow.com/questions/66148135/how-can-i-make-my-customview-conform-to-more-than-one-protocol-in-swiftui February 11, 2021 at 10:56AM

没有评论:

发表评论