Ad

Unwrap String? Into String - Swift

- 1 answer

I am updating information to Firebase Database with a User Default variable.

I have tried YouTubing this, and nothing worked. Stopped at library, nothing shows.

let email = UserDefaults.standard.object(forKey: "EMAIL") as? String
self.databaseRefer.child(email).childByAutoId().setValue("Visal")

The Output is always the SIBGART error on the iOS Debug Statement

I expect the output to be normal, and update info to firebase

Ad

Answer

Try this.

guard let email = UserDefaults.standard.string(forKey: "EMAIL") else {
   return
}

self.databaseRefer.child(email).childByAutoId().setValue("Visal")
Ad
source: stackoverflow.com
Ad