How to save password in UserDefault using the NSUserDefault?
<p>I want to save password when user select remember me checkbox. I have code like this:is this correct?</p>

<p>In Appdelegate.m</p>

<pre><code>@property(strong,nonatomic)NSString *savedno;
</code></pre>

<p>in .m file</p>

<pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{    
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

    // Override point for customization after application launch.
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];

    self.navcontrol =[[UINavigationController alloc]initWithRootViewController:self.viewController ];

    self.window.rootViewController = self.navcontrol;
    [self.window makeKeyAndVisible];

    self.savedno=[[NSUserDefaults standardUserDefaults]objectForKey:@"pass"];

    if(savedno==nil)
    {
        NSDictionary *saveDict=[NSDictionary dictionaryWithObject:savedno forKey:@"pass"];
        [[NSUserDefaults standardUserDefaults]registerDefaults:saveDict];
    }
    return YES;
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    /*
     Called when the application is about to terminate.
     Save data if appropriate.
     See also applicationDidEnterBackground:.
     */

    NSUserDefaults *userdefault=[NSUserDefaults standardUserDefaults];
    [userdefault setObject:savedno forKey:@"pass"];
}
</code></pre>

<p>//ViewDelegate.m file</p>

<p>//event of checkbox</p>

<pre><code>-(IBAction)check:(id)sender
{
    if (checkboxSelected == 0)
    {
        [checkboxButton setSelected:YES];
        [checkboxButton setImage:[UIImage imageNamed:@"checkbox-checked.png"]forState:UIControlStateNormal];

        // userdefault=[NSUserDefaults standardUserDefaults];
        // [userdefault setObject:user.text forKey:@"user"];
        // [userdefault setObject:pass.text forKey:@"pass"];
        self.callno=pass.text;
        pass.text=self.callno;
        AppDelegate *appdelegate=[[UIApplication sharedApplication]delegate];
        appdelegate.savedno=self.callno;

        NSLog(@"Data saved");    
        checkboxSelected = 1;        
    }
    else
    {
        [checkboxButton setSelected:NO];
        [checkboxButton setImage:[UIImage imageNamed:@"checkbox.png"]forState:UIControlStateNormal];                                 
        user.text=@"";
        pass.text=@"";
        checkboxSelected = 0;
    }
}

- (void)viewDidLoad
{
    user.clearButtonMode=UITextFieldViewModeWhileEditing;

    AppDelegate *appdel=[[UIApplication sharedApplication]delegate];

    if([user.text isEqualToString:@"bhoomi"])
    {
        pass.text=appdel.savedno;
    }
    [super viewDidLoad];

    checkboxSelected = 0;

    // Do any additional setup after loading the view, typically from a nib.
}
`
</code></pre>
