我已将其输入到我的 .m 文件中 -StudentLoginViewController
并且编译器不断给我错误:
“NOSbject”没有可见的@interface 声明选择器“viewDidLoad”
这是我的代码:
// StudentLoginViewController.h
#import <UIKit/UIKit.h>
@interface StudentLoginViewController : NSObject <UITextFieldDelegate> {
IBOutlet UILabel *Username ,*Password ;
IBOutlet UIButton *LoginButton ;
IBOutlet UITextField *UsernameText ,*PasswordText;
}
@end
// StudentLoginViewController.m
#import "StudentLoginViewController.h"
@interface StudentLoginViewController ()
@end
@implementation StudentLoginViewController
- (void)viewDidLoad {
[super viewDidLoad];
UsernameText.delegate=self;
PasswordText.delegate=self;
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
// this text will not be updated to the newest text yet,
// but we know what what the user just did to get into a string
NSString *Username, *Password;
if (textField == UsernameText) {
Username = @"jzarate";
Password = PasswordText.text;
} else {
Username= UsernameText.text;
Password = @"14054";
}
// If both the username and password are correct then enable the button
LoginButton.enabled = ([Username isEqualToString:@"jzarate"] && [Password isEqualToString:@"14054"]);
// return YES so that the users edits are used
return YES;
}
@end
请注意,.m 文件上面的代码是其中的所有代码,我已经删除了上面和下面的其他位。