iOS实现登录验证

www.2cto.com/kf/201501/369319.html


-(void)login:(id)sender{

AFHTTPRequestOperationManager *manager=[AFHTTPRequestOperationManager manager];

NSString *url=@"http://172.18.144.248:8080/upload_file_service/LoginServlet";

manager.responseSerializer.acceptableContentTypes=[NSSet setWithObjects:@"text/html",nil];

NSDictionary *namepwd=@{@"user":@"admin",@"pass":@"123"};

[manager POST:url parameters:namepwd success:^(AFHTTPRequestOperation *operation, id responseObject) {

NSLog(@"post-->%@",responseObject);

NSDictionary *datare=[[NSDictionary alloc] init];

datare=responseObject;

re=[datare objectForKey:@"userId"];

appStatus *transvalue=[appStatus shareInstance];

mainViewController *mainView=[self.storyboard instantiateViewControllerWithIdentifier:@"second"];

mainView.delegate=self;

transvalue.contextStr=__name.text;

NSNumber *fre=[[NSNumber alloc]initWithInt:10];

BOOL flag=[fre isEqualToNumber:re];

if(flag){

[self presentViewController:mainView animated:YES completion:nil];

}

} failure:^(AFHTTPRequestOperation *operation, NSError *error) {

NSLog(@"%@",@”用户名或者密码错误”);

}];

}

你可能感兴趣的:(iOS实现登录验证)