mercredi 17 février 2021

If Statement SwiftUI

I have an if statement in my SwiftUI view VStack to toggle an integer which stops a SQLite database from being created more than once, but I'm given numerous errors, stopping the code from building. The variable (appInfo.toggleswitch is an integer set to 0 by default in a class, which I subscribe to in this view using a environment object)

        if appInfo.toggleswitch == 0 {
            let db = DBHelper()
            $appInfo.toggleswitch = 1 }

Aucun commentaire:

Enregistrer un commentaire