ios - Passing data from login controller to frontviewcontroller of SWRevealViewController -


i'm sorry english.

my question how pass data login viewcontroller frontviewcontroller of swrevealviewcontroller library. let me explain situation.

my app has login view. if login informations ok can enter inside app menu managed swrevealviewcontroller.

this storyboard:

mystoryboard app

to "remember" user logged-in want pass id loginview (in storyboard called "view controller") "homeappviewcontroller".

in viewcontroller prepareforsegue method wrote code:

-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{   if ([[segue identifier] isequaltostring:@"entrataapp"]) {     swrevealviewcontroller *destination = [segue destinationviewcontroller];     uinavigationcontroller *navviewcontroller = (uinavigationcontroller *) [destination frontviewcontroller];     homeappviewcontroller *destviewcontroller = (homeappviewcontroller* )[navviewcontroller topviewcontroller];     destviewcontroller.testopassato = risposta;   } } 

and in homeappviewcontrollerthis viewdidload:

- (void)viewdidload{    [super viewdidload];    // additional setup after loading view.    self.title = @"news";     // set side bar button action. when it's tapped, it'll show sidebar.    _sidebarbutton.target = self.revealviewcontroller;    _sidebarbutton.action = @selector(revealtoggle:);     // set gesture    [self.view addgesturerecognizer:self.revealviewcontroller.pangesturerecognizer];     _datipassati.text = _testopassato; } 

as can see try pass "risposta" contain "user id" destviewcontroller.testopassato label inside homeappviewcontroller when launch code label staies empty.

in opinion error? maybe need define homeappviewcontroller frontviewcontroller? how can that?

i'm sorry if question stupid i'm new in ios app development.

i think need know logged in user through out application can store user id when user log in response of webservice

you can store using following

[[nsuserdefaults standarduserdefaults] setvalue:[dictdata valueforkey:@"id"] forkey:@"uid"]; 

here dictdata response dictionary , field id

further add these constant or in .pch file

#define userid     [[nsuserdefaults standarduserdefaults] valueforkey:@"uid"] 

and use userid ever need in application in viewcontroller in class.

when want provide logout facility in application give

nsstring *appdomain = [[nsbundle mainbundle] bundleidentifier]; [[nsuserdefaults standarduserdefaults] removepersistentdomainforname:appdomain]; 

these remove keys , again when execute application go login page.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -