objective c - Issue retrieving data from firebase database ios -


at moment have app using firebase database store users: name school subject within 3 separate textfields.

right i've managed allow user enter details within these 3 text fields , hit button labeled update, sends data firebase console.

this means user can enter details, hit update , see them while logged in. logout , login again textfields blank, despite fact firebase has info stored on server.

i've been playing around day trying work no avail.

here have firebase reference , auth:

    self.rootref = [[firdatabase database] reference];       self.user = [firauth auth].currentuser;  

and update button code sends users info firebase database:

- (ibaction)didtapeditprofile:(id)sender {    if (![_textfieldone.text  isequal: @""]) {        nsstring *item = _textfieldone.text;        [[[[_rootref child:@"users"] child:_user.uid] child:@"name"] setvalue:item];   }    if (![_textfieldtwo.text  isequal: @""]) {        nsstring *itemtwo = _textfieldtwo.text;        [[[[_rootref child:@"users"] child:_user.uid] child:@"school"] setvalue:itemtwo];    }    if (![_textfieldthree.text  isequal: @""]) {        nsstring *itemthree = _textfieldthree.text;        [[[[_rootref child:@"users"] child:_user.uid] child:@"subject"] setvalue:itemthree];    }    }   

the problem i'm having retrieving data within code below situated in viewdidappear:

    [[_rootref child:@"users"] observeeventtype:firdataeventtypevalue withblock:^(firdatasnapshot * _nonnull snapshot) {        nsdictionary *usersdict = snapshot.value;        nslog(@"%@",usersdict);       [usersdict objectforkey:_user.uid];       //i've tried numerous solutions here text fields display info database        mainly:   nsstring *field;  field = _textfieldone.text;  field = [userdict objectforkey @"name"];   code i'm attempting translate looks this:      field(userdict?.objectforkey("name") as? string)  }];  

any ideas?

i managed sorted follows:

-(void)configure:(nsstring *)field {      _textfieldone.text = field;  } 

and within code having problem:

    [[_rootref child:@"users"] observeeventtype:firdataeventtypevalue withblock:^(firdatasnapshot * _nonnull snapshot) {        nsdictionary *usersdict = snapshot.value;        nslog(@"%@",usersdict);        [usersdict objectforkey:_user.uid];        [self configure:[userdict objectforkey:@"name"]];   }];  

thanks help.


Comments

Popular posts from this blog

serialization - Convert Any type in scala to Array[Byte] and back -

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -