Reputation: 1
I’m kinda new to Swift and when I run my code in SwiftPlaygrounds on my iPad, I get those two errors:
ollRow & ollView -> Instance member 'ollName' cannot be used on type 'ollCase'; did you mean to use a value of this type instead?
+
ollView -> Cannot convert value of type 'ollCase.Type' to expected argument type 'Range<Int>'
+ Argument passes to call that takes no arguments
I initialized my data ollCase
with a name and an image but when I try to use the data like this for example: Text(ollCase.ollName)
I get the error and I don‘t understand what‘s wrong.
Here is the complete code:
allOLLCasesView:
import SwiftUI
struct ollCase : Identifiable {
var ollName : String
var ollImage : Image
var id = UUID()
}
class allOLLCases : ObservableObject {
@Published var OLLCases = [
ollCase(ollName: "1", ollImage: Image("1")),
ollCase(ollName: "2", ollImage: Image("2")),
ollCase(ollName: "3", ollImage: Image("3")),
]
}
OLLRowView:
import SwiftUI
struct ollRow: View {
var body: some View {
HStack {
Text(ollCase.ollName)
.padding()
Spacer()
Image(ollCase.ollImage)
.resizable()
.scaledToFit()
.padding()
}
}
}
OLLDetailView:
import SwiftUI
struct ollDetail: View {
var body: some View {
Text("Hello")
}
OLLView:
importSwiftUI
struct ollView: View {
@EnvironmentObject var data : allOLLCases
var body: some View {
NavigationSplitView {
List {
ForEach(ollCase) { Case in
NavigationLink {
ollDetail()
.navigationTitle(ollCase.ollName)
} label: {
ollRow(case: Case)
}
}
}
} detail: {
Text("...")
}
}
}
It would be awesome if someone could help me und explain what I did wrong and what to correct!
I have tried all kinds of defining/switching variables, but I can't seem to find the right solution…
Upvotes: 0
Views: 86