我不断收到此错误“结果 == 失败 -------------”
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);
}];
}