我有IBAction和Method。我的目的我想調用buttonSignIn的IBAction到方法getData中。在這種情況下,我希望此應用程序自動登錄而不輸入用戶名和密碼,但它不起作用。這裏是我的代碼如下:以其他方法調用IBAction自動執行
-(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];但它不起作用。請幫忙。
[自buttonSignIn:自]應該調用方法 「buttonSignIn」。你的調試信息是什麼? – Sisi
當我調試它的步驟buttonSignIn但界面它不工作(不登錄),但調試工作正常。 – user1628083
你是什麼意思「調試工作正常」?如果它觸發buttonSignIn方法,那麼它不是[selfkeySignIn:self]的問題 – Sisi