Post

Replies

Boosts

Views

Activity

Reply to How to solve "Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates." error?
I got the error to go away by changing the .onAppear modifier to .task on a SwiftUI view observing a published property. Below the navigation title modifier of the view. .navigationTitle("Where you're at") .task { // Fetch data from CloudKit here viewModel.fetchData() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’23
Reply to How to solve "Publishing changes from background threads is not allowed; make sure to publish values from the main thread (via operators like receive(on:)) on model updates." error?
I got the error to go away by changing the .onAppear modifier to .task on a SwiftUI view observing a published property. Below the navigation title modifier of the view. .navigationTitle("Where you're at") .task { // Fetch data from CloudKit here viewModel.fetchData() }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’23