My StartView
is outlined like:
import SwiftUI
struct StartView: View {
@State personal var fetchingMessage: String = ""
personal var assistant = CloudAssistant.shared
var physique: some View {
if !fetchingMessage.isEmpty {
ZStack {
Shade.brown
.ignoresSafeArea()
Textual content(fetchingMessage)
.font(.largeTitle)
.foregroundColor(.white)
}
} else {
Textual content("Preliminary View")
.onAppear {
Job {
strive await assistant.fetchAllChangesAsync(message: $fetchingMessage)
}
}
}
}
}
That is how I outlined CloudAssistant
right here:
@MainActor
@Observable
class CloudAssistant {
@Binding personal var progressInfo: String?
static let shared = CloudAssistant(container: CKContainer(identifier: "{id}"))
func fetchAllChangesAsync(message: Binding? = nil) async throws {
if let message = message {
self._progressInfo = message
}
strive await fetchPrivateZoneChangesAsync()
strive await fetchSharedDatabaseChangesAsync()
strive await fetchSharedZoneChangesAsync()
// inside every of above async strategies there's a place to replace progressInfo
// like "Fetched 78 information", "Saving 45 information" and so forth...
// On the finish it must be emptied.
}
}
However my present resolution doesnt even compile;)
What’s one of the simplest ways to perform that? You would possibly already see what I need to obtain;)
There may be in fact choice with completionBlock inside fetchAllChangesAsync
however I hope we are able to do it extra Swifty;)