Does not exit from the observe block.
Doesn't print hello or events.
Stuck on fetching from database.
Displays the data from Firebase but not outside the block.
For example :
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let databaseRef = FIRDatabase.database().reference()
databaseRef.child("Events").queryOrderedByKey().observe(.childAdded, with: {
snapshot in
print(snapshot)
var temp : event = event()
temp.name = (snapshot.value as? NSDictionary)?["name"] as? String ?? ""
temp.description = (snapshot.value as? NSDictionary)?["description"] as? String ?? ""
temp.date = (snapshot.value as? NSDictionary)?["date"] as? String ?? ""
temp.price = (snapshot.value as? NSDictionary)?["price"] as? String ?? ""
temp.venue = (snapshot.value as? NSDictionary)?["venue"] as? String ?? ""
temp.genre1 = (snapshot.value as? NSDictionary)?["genre1"] as? String ?? ""
temp.genre2 = (snapshot.value as? NSDictionary)?["genre2"] as? String ?? ""
temp.img = (snapshot.value as? NSDictionary)?["img"] as? String ?? ""
self.events.append(temp)
print(self.events)
})
print("Hello")
print(self.events)
}
Thanks in advance!