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

python - Selenium remoteWebDriver (& SauceLabs) Firefox moseMoveTo action exception -

html - How to custom Bootstrap grid height? -

Ansible warning on jinja2 braces on when -