Talktobijju
Talktobijju

Reputation: 450

have to save UITextfield's value to the NSUserDefault

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

Answers (1)

jamapag
jamapag

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

Related Questions