iphone - How to keep given password in mgtwitterengine api -


i want keep password given user in variable. password value. in code containing username. using mgtwitterengine api in application. here function printing data on console.

-(void)setusername:(nsstring *)newusername password:(nsstring *)newpassword {      nslog(@"uset sername %@ , password %@",newusername,newpassword);      ... } 

i debug in function saw function running after loggedin. printing null in password value although username printing well. i have trace tweet value of user. went through mgtwitterengine. there block of code necessary write username , password.

here code

mgtwitterengine *twitterengine = [[mgtwitterengine alloc] initwithdelegate:self];   [twitterengine setusername:@"username" password:@"password"];  // updates people authenticated user follows.   nsstring *connectionid = [twitterengine getfollowedtimelinefor:nil since:nil startingatpage:0]; 

please me how keep password ?

read developer documentation, provides info need easy this. question, there're couple of ways how can save data.

nsuserdefaults: can save username , password using class this:

[[nsuserdefaults shareduserdefaults] setobject:username forkey:@"username"]; [[nsuserdefaults shareduserdefaults] setobject:username forkey:@"password"]; [[nsuserdefaults shareduserdefaults] synchronize]; 

once need data again, call it:

nsstring*username = [[nsuserdefaults standarduserdefaults] objectforkey:@"username"]; nsstring*password = [[nsuserdefaults standarduserdefaults] objectforkey:@"password"]; 

or:

nsdictionary: if don't want rely on nsuserdefaults, can save login data in nsdictionary , save sandbox. works this:

nsmutabledictionary*logindictionary = [[nsmutabledictionary alloc] init]; [logindictionary setobject:username forkey:@"username"]; [logindictionary setobject:password forkey:@"password"]; [logindictionary writetofile://your path here atomically:no];  [logindictionary release]; 

then, once need data again, read file:

nsmutabledictionary*logindictionary = [[nsmutabledictionary alloc] initwithcontentsoffile://your path];  nsstring*username = [logindictionary objectforkey:@"username"]; nsstring*password = [logindictionary objectforkey:@"password"];  [logindictionary release]; 

hope helps!


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -