我已經輸入到這一點我.m文件 - StudentLoginViewController
- 和編譯器不斷給我的錯誤:缺少方法聲明
no visible @interface for 'NOSbject' declares the selector '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文件的代碼是其中的所有代碼,我已經刪除了上面和下面的其他位。
這有**絕對*不***做:
[super viewDidLoad];
寫:那麼,你是在得到錯誤Xcode也不用'if語句。 – 2013-03-28 07:10:31
是什麼促使你爲超類選擇「NSObject」? – 2013-03-28 07:11:44
我沒有提示它,它自己做了,當我去玩它的IOS IPhone6.1發電機 – 2013-03-28 07:16:54