Cannot convert the value of type '[String]' to expected argument type 'String' : while appending arrays to get data from Fireabse in table view cell

后端 未结 1 404
执笔经年
执笔经年 2021-01-20 18:01

Getting error while appending arrays in snapshot. I want to retrieve all values from these arrays EngNames , UrNames and cakeImages in

相关标签:
1条回答
  • 2021-01-20 18:26

    You are passing arrays to String parameters in your initialiser for the Cake struct. Try something like

    for (i, snap) in snapshot.children.enumerated() {
        if let node = snap as? FIRDataSnapshot ,  let rate = node.value as? Int {
            self.cakes.append(Cake(cakeEngNames: EngNames[i],
                                   cakeUrNames: UrNames[i],
                                   cakeImages: cakeImages[i],
                                   cakeRates: String(rate)))
        }
    }
    

    assuming that the three arrays you define at the top, are supposed to map to the various parameters of the different cakes. Here you take the relevant entry from each array, rather than passing the whole array.

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