Password test in 1st Tab.m to load a loginView gives class error?

Posted by Michael Robinson on Stack Overflow See other posts from Stack Overflow or by Michael Robinson
Published on 2010-06-08T00:23:36Z Indexed on 2010/06/08 16:22 UTC
Read the original article Hit count: 262

I have a name and password in NSUserDefaults for login. I have this in my 1stTab View.m class to test for presence and load a login/signup loginView.xib modally if there is no password or name stored in the app.

Here is the pulling of the defaults:

-(void)refreshFields {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    usernameLabel.text = [defaults objectForKey:kUsernameKey];
    passwordLabel.text = [defaults objectForKey:kPasswordKey];
{

Here is the Test:

- (void)viewDidAppear:(BOOL)animated {
        [self refreshFields];
        [super viewDidAppear:animated];

    if ([usernameLabel.text length] == 0 || [passwordLabel.text length] == 0)
{
    LoginViewController * vc = [[[LoginViewController alloc] initWithNibName:@"LoginView" bundle:nil] autorelease];
    [self presentModalViewController:vc animated: false];
}
else 
{
    [[self tableView ]reloadData];
}

}

Thanks in advance, I'm getting this error in the console:

* Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key usernameLabel.'

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsuserdefaults