SwiftUI Cannot convert value of type Type to expected argument type

Hi,

I'm building a dynamic list, and I'm having trouble with the code. I had it working in Xcode 12 Beta, but the same code will not work in Xcode 11.

Xcode is prompting me to pass "senateData: [SenateData]", but when I do it fails to build with the message "Cannot convert value of type '[SenateData].Type' to expected argument type '[SenateData]'."

In Xcode 12 Beta is worked fine with me passing "senateData: senateData" but when I do it in Xcode 11, I get the message "Use of unresolved identifier 'senateData'."

Thank you in advance for your assistance.

Code Block
import SwiftUI
struct SenateList2: View {
    var senateData: [SenateData]
    var body: some View {
        List {
            ForEach(self.senateData, id: \.self) { senateData in
                HStack {
                    Rectangle()
                        .fill(Color(senateData.party))
                        .frame(width: 6, height: 26)
                        .offset(y: 1)
                    VStack(alignment: .leading) {
                        Text("\(senateData.firstName) \(senateData.lastName)")
                            .fontWeight(.medium)
                            .font(.system(size: 14))
                        Text((senateData.party))
                            .font(.system(size: 12))
                            .font(.subheadline)
                            .foregroundColor(.secondary)
                    }
                    Spacer()
                    VStack(alignment: .trailing) {
                        Text("\(senateData.senateClass) – Senator")
                            .font(.system(size: 12))
                            .fontWeight(.medium)
                            .font(.subheadline)
                        Text((senateData.stateFullName))
                            .font(.system(size: 12))
                            .font(.subheadline)
                            .foregroundColor(.secondary)
                    }
                }
            }
        }.listStyle(GroupedListStyle())
    }
}
struct SenateList2_Previews: PreviewProvider {
    static var previews: some View {
        SenateList2(senateData: [SenateData])
    }
}

To SenateList2.init(senateData:), you need to pass an Array of SenateData.
[SenateData] is Array type, not an Array.

Please try something like this:
Code Block
        SenateList2(senateData: [SenateData(/*...*/)])

The part shown as /*...*/ depends on how you defined SenateData.



In Xcode 12 Beta is worked fine with me passing "senateData: senateData" 

Tried in Xcode 12 beta 4, it produced the error: Cannot find 'senateData' in scope
SwiftUI Cannot convert value of type Type to expected argument type
 
 
Q