Reputation:
Long time reader. First-time question from a beginner trying to learn Swift. This is a total noob-level question, but I haven't been able to find an answer, so I apologize in advance for my own stupidity and the simplicity of this question.
I am trying to pass an array into a function, but I get the following error: Cannot convert value of type '[String].Type' to expected type '[String]'
.
func confirmAndSend() {
startTitleInstructions.text = "confirm and send your survey"
confirmStackView.isHidden = false
populateConfirmStack(attributesChosen: [String])
}
func populateConfirmStack(attributesChosen: [String]) {
confirmLabel1.text = attributesChosen[0]
confirmLabel2.text = attributesChosen[1]
confirmLabel3.text = attributesChosen[2]
confirmLabel4.text = attributesChosen[3]
confirmLabel5.text = attributesChosen[4]
}
The attributesChosen
argument was defined as an empty Array
, type String
, and it was populated by users choosing up to five options, that were appended to the empty Array
. What I am trying to do in this step is confirm the attributes chosen, by displaying the five options selected earlier.
I've tried several different approaches on how to word and structure it, following other examples with Int I have seen listed here, but nothing has worked for me. This seems like it should be very easy, and I'm guessing it is an obvious syntax mistake, one of which I have not been able to sort out on my own.
Thanks for the help!
Upvotes: 1
Views: 66
Reputation: 171
You are sending array of type , which should be array of string values ["a", "b"]
Upvotes: 1