Hi Everyone, I don't know if this is the right place for this but I am getting this error and I don't know how to fix it.
import SwiftUI
struct StartTabView: View {
(at)EnvironmentObject var myEvents: EventStore
(at)EnvironmentObject var myEventsJunk: JunkEventStore
var body: some View {
TabView{
EventsListView()
.tabItem {
Label("List", systemImage: "list.triangle")
}
EventsJunkView()
.tabItem {
Label("Junk Drawer", systemImage: "tray")
}
EventsCalendarView()
.tabItem {
Label("Calendar", systemImage: "calendar")
}
}
}
}
struct StartTabView_Previews: PreviewProvider {
static var previews: some View {
StartTabView()
.environmentObject(JunkEventStore(preview: true))
.environmentObject(EventStore(preview: true))
}
}'
import Foundation
(at)MainActor
class JunkEventStore:ObservableObject {
(at)Published var events = Junk
(at)Published var preview: Bool
(at)Published var changedEvent: Junk?
(at)Published var movedEvent: Junk?
init(preview: Bool = false) {
self.preview = preview
fetchEvents()
}
func fetchEvents() {
if preview {
events = Junk.sampleEvents
} else {
// load from your persistence store
}
}
func delete(_ event: Junk) {
if let index = events.firstIndex(where: {$0.id == event.id}) {
changedEvent = events.remove(at: index)
}
}
func add(_ event: Junk) {
events.append(event)
changedEvent = event
}
func update(_ event: Junk) {
if let index = events.firstIndex(where: {$0.id == event.id}) {
movedEvent = events[index]
events[index].note = event.note
events[index].eventType = event.eventType
changedEvent = event
}
}
} <
This is my code where I believe the error is happening but please let me know if you need more context!