如果使用php使用mysql数据库检查登录数据的代码。该代码与AFNetworking 2.0一起使用,但我没有迁移到AFNetworking 3.0。 我根据GitHub文档修改了代码。
但是我遇到了这个错误!
如果我删除此代码,错误就会消失!
NSURL *URL = [NSURL URLWithString:stringURL];
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:URL.absoluteString parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject)
{
// dismiss uiviewController after data loading is done
[self dismissViewControllerAnimated:NO completion:nil];
//NSLog(@"success");
NSDictionary *temp = [[NSDictionary alloc]init ];
temp = (NSDictionary *)responseObject;
if(temp.count > 0)
{
NSDictionary *TeacherInfo = responseObject[0];
TeacherName = TeacherInfo[@"Teacher_Name"];
TeacherID = TeacherInfo[@"Teacher_NO"];
IsUserAdmin = TeacherInfo[@"IsAdmin"];
TeacherSubject1 = TeacherInfo[@"Subject1No"];
TeacherSubject2 = TeacherInfo[@"Subject2No"];
TeacherSubject3 = TeacherInfo[@"Subject3No"];
TeacherSubject4 = TeacherInfo[@"Subject4No"];
// ViewController *Navigate = (ViewController *)
// [self.storyboard instantiateViewControllerWithIdentifier:@"ChoicesViewController"];;
// [self presentViewController:Navigate animated:YES completion:nil];
}
else
{
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"wrong user name or password"
message:@"please enter correct data"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
}
}
// if failed to connect
failure:^(NSURLSessionTask *operation, NSError *error)
{
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"connection error"
message:@"" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];
}];