ios - trying to store values from Firebase to NSDictionary -


i accessing firebase database , getting values , storing in property. when try access property outside method getting "null". can me new obj c programming

-(void)buildusersindatabase {      firdatabasereference *referencetodatabase = [[firdatabase database]reference];     [[referencetodatabase child:@"users"]observeeventtype: firdataeventtypechildadded withblock:^(firdatasnapshot * _nonnull snapshot) {         self.dict = @{@"name": snapshot.value[@"name"],                                @"email":snapshot.value[@"email"]};      }]; } 

the method -[firdatabasereference observeeventtype:withblock:] asynchronous; code insisde block executed when observed event occurs.

in contrast, method -buildusersindatabase registers block , exits right away; self.dict nil until observed event happens , pased block executed.

source: firebase official documentation


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -