我有 IBAction 和 Method。我的目的是我想将 buttonSignIn 的 IBAction 调用到方法 getData 中。在这种情况下,我希望这个应用程序自动登录而不输入用户名和密码,但它没有用。下面是我的代码:
-(void)storeData
{
NSString *usr = [_txtUsername stringValue];
NSString *pwd = [_txtPwd stringValue];
NSUserDefaults *store = [NSUserDefaults standardUserDefaults];
[store setObject:usr forKey:@"usrname"];
[store setObject:pwd forKey:@"usrpwd"];
[store synchronize];
}
-(void)getData
{
if ([_remCheckbox state] == NSOnState)
{
NSUserDefaults *store = [NSUserDefaults standardUserDefaults];
NSString *un = [store objectForKey:@"usrname"];
NSString *pw = [store objectForKey:@"usrpwd"];
_txtUsername.stringValue = un;
_txtPwd.stringValue = pw;
//call event IBAction
[self buttonSignIn:self];
}
}
- (IBAction)buttonSignIn:(id)sender
{
[self storeData];
//Code for login suppose to work here
.........
.........
}
我使用 [self buttonSignIn:self]; 但它没有用。请帮忙。