我现在正在开发一个iOS应用程序,我是初学者,我已经遵循树屋课程,并且实际上只需要更多输入字段就可以做同样的事情。我正在尝试从我的signupviewcontroller注册,但我一直收到alertview,我不明白这是怎么可能的,虽然我在课程中指定了类似 - 只是为了显示alertview时的长度输入字段为0.即使填写了每个输入字段,我仍然会收到此错误,谁可以帮我解决此问题?
这是signup.m:
//
// SignUpViewControllerLeverancier.m
// SIKA
//
// Created by BLANCO on 25-04-14.
// Copyright (c) 2014 Sinan Karakurt. All rights reserved.
//
#import "SignUpViewControllerLeverancier.h"
#import <Parse/Parse.h>
@interface SignUpViewControllerLeverancier ()
@end
@implementation SignUpViewControllerLeverancier
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (IBAction)signupLeverancier:(id)sender {
NSString *naamLeverancier = self.naamLeverancierField.text ;
NSString *telefoonLeverancier = [self.telefoonLeverancierField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *bedrijfsnaamLeverancier = self.bedrijfsnaamLeverancierField.text;
NSString *adresLeverancier = self.adresLeverancierField.text;
NSString *postcodeLeverancier = self.postcodeLeverancierField.text;
NSString *stadLeverancier = self.stadLeverancierField.text;
NSString *emailLeverancier = [self.emailLeverancierField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSString *wachtwoordLeverancier = [self.wachtwoordLeverancierField.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
if ([naamLeverancier length] == 0 ||
[telefoonLeverancier length] == 0 ||
[bedrijfsnaamLeverancier length] == 0 ||
[adresLeverancier length] == 0 ||
[postcodeLeverancier length] == 0 ||
[stadLeverancier length] == 0 ||
[emailLeverancier length] == 0 ||
[wachtwoordLeverancier length] == 0)
{
UIAlertView *alertView = [[ UIAlertView alloc] initWithTitle:@"Leeg veld" message:@"Vul de lege velden in" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertView show];
}
else {
PFUser *newUserLeverancier = [PFUser user];
newUserLeverancier[@"naamLeverancier"] = naamLeverancier;
newUserLeverancier[@"telefoonLeverancier"]= telefoonLeverancier;
newUserLeverancier.username = bedrijfsnaamLeverancier;
newUserLeverancier[@"adresLeverancier"] = adresLeverancier;
newUserLeverancier[@"postcodeLeverancier"] = postcodeLeverancier;
newUserLeverancier[@"stadLeverancier"] = stadLeverancier;
newUserLeverancier.email = emailLeverancier;
newUserLeverancier.password = wachtwoordLeverancier;
[newUserLeverancier signUpInBackgroundWithBlock:^(BOOL succeeded, NSError *error) {
if (error) {
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Sorry!" message:[error.userInfo objectForKey:@"error"] delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alertView show];
}
else {
[self.navigationController popToRootViewControllerAnimated:YES];
}
}];
}
}
@end
答案 0 :(得分:1)
也许您没有为您的文本字段连接IBOutlets?尝试记录self.naamLeverancierField以查看它返回的内容。如果那个返回正确的对象,请尝试记录其他对象。忘记连接出口通常是从视图中获取nil对象的原因。