Home > OS >  Xcode - push data into the firebase storage
Xcode - push data into the firebase storage

Time:05-18

I thought to design the program like this.

  1. The user type the data in each text fields; Name, Passwords and Comments.
  2. By press the button, store the input data into the Firebase storage.
  3. However, the error occurred.

I wonder which parts need to fix or add.

Code

Error

private let database = Database.database().reference()

@IBOutlet weak var NameInput: UITextField!
@IBOutlet weak var Passwords: UITextField!
@IBOutlet weak var Rate: UISegmentedControl!
@IBOutlet weak var Comment: UITextField!
@IBOutlet weak var UploadButton: UIButton!

override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view.
}

@IBAction func UbuttonPressed(_ sender: Any) {
   
    let review_data: [String: Any?] = [
        "Name": NameInput.text,
        "Passwords": Passwords.text,
        // "Rate": Rate.text,
        "Comment": Comment.text
    ]

    database.child("Review_\(Int.random(in: 0..<1000))").setValue(review_data)
}

CodePudding user response:

You probably have a storyboard reference to one of the @IBOutlets which you renamed/deleted in your source code, but haven't removed/changed it in the storyboard. See this article for more info.

  • Related