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
Post a Comment