我正在使用Xcode中的某个项目,并从didReceiveMemoryWarning
和incomplete implementation
收到错误。这是主文件:
#import <UIKit/UIKit.h>
#import <Parse/Parse.h>
@interface LoginViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIScrollView *scroller;
@property (weak, nonatomic) IBOutlet UITextField *FirstNameField;
@property (weak, nonatomic) IBOutlet UITextField *SurnameField;
@property (weak, nonatomic) IBOutlet UITextField *EmailField;
@property (weak, nonatomic) IBOutlet UITextField *PasswordField;
@property (weak, nonatomic) IBOutlet UITextField *ReenterPasswordField;
- (IBAction)RegisterAction:(id)sender;
@end
这是.m文件:
#import "LoginViewController.h"
@interface LoginViewController ()
@end
@implementation LoginViewController
@synthesize scroller;
- (void)viewDidLoad
{
[super viewDidLoad];
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(340, 600)];
}
- (void)viewDidAppear:(BOOL)animated
{
PFUser *user = [PFUser currentUser];
if (user.email != nil) {
[self performSegueWithIdentifier:@"login" sender:self];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)RegisterAction:(id)sender {
[_FirstNameField resignFirstResponder];
[_SurnameField resignFirstResponder];
[_EmailField resignFirstResponder];
[_PasswordField resignFirstResponder];
[_ReenterPasswordField resignFirstResponder];
[self checkFieldsComplete];
[self checkFieldsComplete];
}
- (void) checkFieldsComplete {
if ([_FirstNameField.text isEqualToString:@""] || [_SurnameField.text isEqualToString:@""]|| [_EmailField.text isEqualToString:@""] || [_PasswordField.text isEqualToString:@""] || [_ReenterPasswordField.text isEqualToString:@""]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops" message: @"Make sure to complete every field" delegate: nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[alert show];
} else {
[self checkPasswordsMatch];
}
}
- (void) checkPasswordsMatch {
if (![_PasswordField.text isEqualToString:_ReenterPasswordField.text]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Oops" message: @"Passwords don't match" delegate: nil cancelButtonTitle: @"Ok" otherButtonTitles: nil];
[alert show];
}
}
- (void) registerNewUser {
PFUser *newUser;
newUser.username = [NSString stringWithFormat: _FirstNameField.text, _SurnameField.text];
newUser.email = _EmailField.text;
newUser.password = _PasswordField.text;
[newUser signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (!error) {
NSLog(@"Welcome to Vici!");
[self performSegueWithIdentifier:@"login"
sender:self];
} else {
NSLog(@"There was an error in registration");
}
}];
}
@end
有人能指出解决方案吗?
答案 0 :(得分:3)
你错过了viewDidAppear
的右大括号,因此它被@implementation
的其余部分弄糊涂了并抱怨,因为它没有找到RegisterAction
。它会在didReceiveMemoryWarning
向您显示警告,因为这是您缺少大括号后的第一段代码(显示了将来如何找到问题)。
添加缺失的大括号,您应该通过此错误。