Getting error while appending arrays in snapshot. I want to retrieve all values from these arrays EngNames
, UrNames
and cakeImages
in
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.