Reputation: 450
I am a new comer to the iPhone world, I am having a question,I am having a login page in which 2 levels and associated 2 uitextfield,i have to save both the UITextfield's Values(inputt by user) to the NSUserDefault,and new time when we start application both the UITextfield should be filled with the values we hav input before....i am in bid trouble
code would be appreciated
Thanx in advance
Upvotes: 1
Views: 522
Reputation: 9318
-(void)saveLoginToUserDefaults:(NSString*)loginString
{
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
if (standardUserDefaults) {
[standardUserDefaults setObject:loginString forKey:@"Login"];
}
}
-(NSString*)retrieveLoginFromUserDefaults
{
NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults];
NSString *val = nil;
if (standardUserDefaults)
val = [standardUserDefaults objectForKey:@"Login"];
return val;
}
Upvotes: 3