-1

I'm working on a project in Xcode and getting an error from didReceiveMemoryWarning and incomplete implementation. This is the main file:

#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

This is .m file:

#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

Can anyone point out a solution?

4

1 回答 1

3

你在 处缺少一个右括号viewDidAppear,因此它被其他人弄糊涂了,@implementation并抱怨,因为它没有找到RegisterAction结果。它向您显示警告,didReceiveMemoryWarning因为这是您丢失大括号后的第一段代码(它向您展示了如何在未来找到问题)。

添加缺少的大括号,您应该可以克服此错误。

于 2013-09-14T03:28:46.273 回答