- ForEach(ModelCategory.allCases, id: .self) { category in
The error message says "Missing argument for parameter #1 in call"
How do I fix this?
The error message says "Missing argument for parameter #1 in call"
How do I fix this?
Did you try with\
:
ForEach(ModelCategory.allCases, id: \.self) { category in
What is ModelCategory in this ForEach ? It should be an instance of the class, not the class itself.
What is ModelCategory in this ForEach ? It should be an instance of the class, not the class itself.
Here's an example of ForEach with an enum:
The enum
enum WordLength : Int, CaseIterable {
case random = 0
case five = 5
case six = 6
case seven = 7
}
The ForEach
ForEach(WordLength.allCases,id:\.self) { wordLength in
Text(String(describing:wordLength).capitalized)
}
The enum doesn't have to be Int: I've taken this example from an app that uses the numeric value (Int) in processing, whereas in the ForEach it's for showing Picker options as text (string).
Regards, Michaela