关闭

log

58人阅读 评论(0) 收藏 举报
分类:

登陆



NSURL *url = [NSURLURLWithString:@"http://192.108.1.109:8080/qqqqq/user/login"];

    NSMutableURLRequest *request = [NSMutableURLRequestrequestWithURL:url];

    request.HTTPMethod = @"POST";

    NSDictionary *dict = @{

                           @"userID":@"111",

                           @"captcha":@"111"

                           };


    NSData *json = [NSJSONSerializationdataWithJSONObject:dict options:0error:nil];

    NSString *rdata=[[NSStringalloc] initWithData:jsonencoding:NSUTF8StringEncoding];

    rdata=[NSString stringWithFormat:@"req=%@",rdata];

    NSLog(@"%@",rdata);

    request.HTTPBody = [rdatadataUsingEncoding:NSUTF8StringEncoding];

    

    [NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueuemainQueue] completionHandler:^(NSURLResponse *_Nullable response, NSData * _Nullable data, NSError * _Nullable connectionError) {

        if (data == nil || connectionError) return;

        NSDictionary *dict = [NSJSONSerializationJSONObjectWithData:data options:NSJSONReadingMutableLeaveserror:nil];

        NSString *result = [[NSStringalloc] initWithData:data encoding:NSUTF8StringEncoding];

        NSLog(@"%@", result);

        NSLog(@"dict=%@", dict);

       

        NSString *error = dict[@"error"];

        if (error) {

            [MBProgressHUD showError:error];

        } else {

            NSString *success = dict[@"success"];

            [MBProgressHUD showSuccess:success];

        }

        

    }];


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:101612次
    • 积分:2035
    • 等级:
    • 排名:第18929名
    • 原创:72篇
    • 转载:69篇
    • 译文:23篇
    • 评论:8条