0

「result == fail -------------」というエラーが表示され続けます

NSLogは言う

email = test;
    firstname = "<UITextField: 0x7ffe7be159b0; frame = (184 71; 132 30); text = 'test'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x600000248340>; layer = <CALayer: 0x60800003c1e0>>";
    lastname = "<UITextField: 0x7ffe7bc0d440; frame = (184 144; 132 30); text = 'test'; clipsToBounds = YES; opaque = NO; autoresize = RM+BM; gestureRecognizers = <NSArray: 0x600000248b50>; layer = <CALayer: 0x6000000384c0>>";
    password = test;

クラスからユーザーの姓、名、メールアドレス、パスワードをウェブサイトに登録しようとしています。

登録するための私のコードは次のとおりです。

(IBAction)createAcct:(id)sender {
    if ([self.firstName.text isEqualToString:@""] || [self.lastName.text isEqualToString:@""] || [self.emailtxt.text isEqualToString:@""] || [self.passwordTxt.text isEqualToString:@""]){
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Dont leave text feild blank!" delegate:self cancelButtonTitle:@"done" otherButtonTitles:nil];
        [alert show];

    }



NSDictionary *parameters = @{@"email": [NSString stringWithFormat:@"%@", _emailtxt.text], @"password": [NSString stringWithFormat:@"%@", _passwordTxt.text], @"firstname" : [NSString stringWithFormat:@"%@", _firstName], @"lastname" : [NSString stringWithFormat: @"%@", _lastName]};

NSLog(@"%@", parameters);

AFHTTPSessionManager *manager = [[AFHTTPSessionManager alloc]initWithSessionConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];

[manager setRequestSerializer:[AFHTTPRequestSerializer serializer]];
[manager setResponseSerializer:[AFJSONResponseSerializer serializer]];

[manager POST:@"http://www.tageninformatics.com/client/jwu/csis3070_assignment3/user/register/" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject){



    NSLog(@"success");

    NSDictionary *data = responseObject;
    NSString *dataString = [NSString stringWithFormat:@"%@", [data objectForKey:@"result"]];
    NSLog(@"result == %@ -------------", dataString);


    if ([dataString isEqualToString:@"success"]){




        [[NSUserDefaults standardUserDefaults] setObject:dataString forKey:@"success"];
        [[NSUserDefaults standardUserDefaults] synchronize];

        NSLog(@"%@", dataString);


        //store the token


    } else {
        //error for storing the token
    }





}
      failure:^(NSURLSessionDataTask * task, NSError * error) {
          NSLog(@"error: %@", error);
      }];

}

4

1 に答える 1

0
NSDictionary *parameters = @{@"email": [NSString stringWithFormat:@"%@", _emailtxt.text], @"password": [NSString stringWithFormat:@"%@", _passwordTxt.text], @"firstname" : [NSString stringWithFormat:@"%@", _firstName], @"lastname" : [NSString stringWithFormat: @"%@", _lastName]};

NSLog(@"%@", parameters);

変更_firstNameする に_firstName.text 変更_lastNameする_lastName.text

そしてさらに試みる

于 2016-10-24T02:40:27.587 に答える