I want to know how I can run some logic func or control flow operator before SwiftUI attempt to render ContentView? where and how I can put my codes?
Updated: init(){} before var body: some Scene
When I use init and do my logic there I cannot find a way to report my results of process, how I can solve this issue?
my code:
import SwiftUI
@main
struct _99App: App
{
init() {
let firstName = "omid"
print(firstName)
}
@State var name : String = firstName // ← Here Error: Cannot find 'firstName' in scope
var body: some Scene {
WindowGroup {
ContentView(name: $name)
}
}
}
PS: basically I need a place to run my logic before any thing happens in app.