How to check for value in Firebase that is held under a autoID child?

后端 未结 1 416
死守一世寂寞
死守一世寂寞 2021-01-26 08:31

Upon the tap of a delete button. I am trying to delete a particular child out of my Firebase database. My problem is that I am unable to refer to the particular childByAut

1条回答
  •  有刺的猬
    2021-01-26 08:49

    Let's start with a simplified structure

    -Uiiasidasod
       item_name: "iMac"
    -Yiimamsmdd
       item_name: "MacBook"
    

    A typical design pattern is to read these items from Firebase and store them in an array of dictionaries. That array is used as a datasource for the tableViews.

    each dictionary is a key:value pair.

    So the first node from above has a Firebase key (parent node name of "Uiiasidasod" and a value of "item_name: iMac" (note the value is a dictionary as well)

    myArray[0] = ["Uiiasidasod": "item_name: 'iMac'"]
    myArray[1] = ["Yiimamsmdd": "item_name: 'MacBook'"]
    

    so when the user swipes row 1 in the table, you fetch the dictionary from the array, row 1. You get the key portion (the Firebase node name) and can then delete it from Firebase.

    0 讨论(0)
提交回复
热议问题