jeudi 1 septembre 2016

Uploading data to Firebase with "IF" and UIPickerController

I started coding a few weeks ago and I am trying to load data to my Firebase.database for my app. But the thing is, that I want the data to load/save into different folders/names ("A" & "B") in my database in firebase so that later i can retrieve the data on 2 different scroll views with one scroll view only showing "A" and one only showing "B".

My code is not throwing errors at me, but for some reason it won't upload data. i don't know why it is not working.

Help highly appreciated. Thanks community !!

CODE INCOMING !!!


/// Picker now

// 2 items for the picker.
var data = ["A", "B"]




func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
    // Column count: use one column.
    return 1
}

func pickerView(pickerView: UIPickerView,
                numberOfRowsInComponent component: Int) -> Int {

    // Row count: rows equals array length.
    return data.count
}

func pickerView(pickerView: UIPickerView,
                titleForRow row: Int,
                            forComponent component: Int) -> String? {

    // Return a string from the array for this row.
    return data[row]
}

func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
    true
}

///Here I try to Upload the image that I picked in UIPickerView

@IBAction func Upload(sender: UIButton){

    func simplePicker(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {

        if component == 0 {

            func Upload(){
            _ = UIImage.self
            FIRDatabase.database().reference().childByAutoId().setValue("A")
            }}

        if component == 1 {

            func Upload(){
            _ = UIImage.self
            FIRDatabase.database().reference().childByAutoId().setValue("B")
            }}


    }

}

Aucun commentaire:

Enregistrer un commentaire