json - Storing values pulled from server in iOS development -


i newbie ios development.

how , store values pull server @ time of authentication? developing app uses login screen. once try login, sends json post api , server responds. unique userid. how , should store unique user id can use pull data across different views? after loggin in, goes different view controller. there global variable or storage can access in view controller?

thanks.

you can store data in dictionary ,then can use user defaults pass values this

nsdata *urldata=[nsurlconnection sendsynchronousrequest:request returningresponse:&response error:&error];  nsstring *data=[[nsstring alloc]initwithdata:urldata encoding:nsutf8stringencoding];   nsarray *dataarr=[data jsonvalue];  (int i=0; i<[dataarr count]; i++) {      nsdictionary *dict=[dataarr objectatindex:i];       nsstring *codev=[dict valueforkey:@"userid"];    [nsuserdefault standasduserdefault]setobject: dict forkey :@"logindata"];     nslog(); }      nslog(@"%@", json_string); 

another view

-(void) viewdidload{    nsdictionary *dict = [nsuserdefault standarduserdefault]objectforkey:@"logindata"] nslog(@"dict %@",dict); } 

Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -