Swift Quiz App Error (Static method 'buildExpression' requires that 'ChoiceTextView' conform to 'View')

Hello,
I have encountered an error I can´t seem to fix in the iOS Quiz App course.

import SwiftUI
import Foundation

struct ChoiceTextView {
    let choiceText: String
    let accentColor = Color(red: 48/255, green: 105/255, blue: 240/255)
    
    var body: some View {
        Text(choiceText)
            .font(.body)
            .bold()
            .multilineTextAlignment(.center)
            .padding()
            .border(accentColor, width: 4)
    }
}

struct ChoiceTextView_Previews: PreviewProvider {
    static var previews: some View {
        ChoiceTextView(choiceText: "Choice Text")
    }
}

Throws me out the Error:

Google hasn´t been too helpful and I am quite new to programming so I don´t quite understand what I did wrong here.

Anyway hopefully it´s not a stupid question.

If you change this to struct ChoiceTextView: View {

Does that help?

Hey,

Yes that solved the problem, thank you very much!

1 Like