I have created a struct to store data that needs to be read and written to. This is how I've set it up.
struct countdowns: Codable {
var newEvents: [newEvent]
}
struct newEvent: Codable {
var date = dateComponent()
var time = dateComponent()
var name: String
}
This is the code that is writing to it.
struct NewDateView: View {
var body: some View {
VStack {
Spacer() .frame(minHeight: 6, maxHeight: 6)
HStack {
Text("Add New Event")
.headerStyle()
}
ExtendedDivider()
.padding(.top, -1.0)
.frame(height: 0.7)
TextField("New event.", text: countdowns.newEvents.name)
Spacer()
}
.frame(minWidth: 600, maxWidth: .infinity, minHeight: 500, maxHeight: .infinity)
}
}
The TextField is returning two errors:
Instance member 'newEvents' cannot be used on type 'countdowns'; did you mean to use a value of this type instead?
Value of type '[newEvent]' has no member 'name'
The one thats particularly stumping me is the second error, as as far as I'm aware, I haven't made any typos or anything that would stop name
from being recognised. I'm relatively new to Swift, but I know this should be an easy fix but I can't seem to figure it out. Any help would be greatly appreciated.
Cheers