관찰 블록을 종료하지 않습니다.스위프트 : 종료하지 않음 Firebase가 fuction 블록을 관찰합니다.
안녕하세요 또는 이벤트를 인쇄하지 않습니다.
데이터베이스에서 페치를 계속합니다.
Firebase의 데이터를 표시하지만 블록 외부는 표시하지 않습니다. 예를 들어
: 사전에
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)
}
감사합니다! 여기
참조 http://stackoverflow.com/questions/39067196/using-variables-outside-of-completion-block –