I have a 'while' loop that is checking Firebase for some prices on a menu. For each item, it goes to a specific ref URL and grabs that dish's price, then commits it's value to an array to be displayed on a table.
var i = 0 while i < self.itemNames.count { itemNameRef.childByAppendingPath("\(self.itemNames[i])/itemPrice").observeEventType(.Value, withBlock: { snapshot in self.itemPrices.append(snapshot.value as! String) }) i++ } Thing is, it seems to clear my entire array once it exits the observeEventType enclosure. I've placed some print() statements throughout the loop, and found that I can get it to print the array as it appends if the statement is directly beneath the appending code, but outside the }), it only returns an empty array.
What is going on here? Thanks!
for itemName in itemNamesthere.