iOSAFNetWorking下同步异步请求

//阻塞

创新互联建站是一家专注于网站建设、网站制作与策划设计,卢氏网站建设哪家好?创新互联建站做网站,专注于网站建设10多年,网设计领域的专业建站公司;建站业务涵盖:卢氏等地区。卢氏做网站价格咨询:13518219792

- (User *)findUser:(NSNumber *)userID

{

    NSString *url = [NSString stringWithFormat:@"%@/s/account/find-user/",ServerBaseURL];

    NSMutableDictionary *requestParms = [[NSMutableDictionary alloc] init];

    [requestParms setObject:userID forKey:@"userId"];

    

    AFJSONRequestSerializer *requestSerializer = [AFJSONRequestSerializer serializer];

    NSMutableURLRequest *request = [requestSerializer requestWithMethod:@"POST" URLString:url parameters:requestParms error:nil];

    

    AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

    AFHTTPResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializer];

    

    [requestOperation setResponseSerializer:responseSerializer];

    [requestOperation start];

    [requestOperation waitUntilFinished];

    

    NSDictionary *userInfo = [[requestOperation responseObject] objectForKey:@"user"];

    

    if (userInfo != nil) {

这里对结果处理

return xxxx

    }

    return nil;

}

//异步

    NSString *url = [NSString stringWithFormat:@"%@/s/account/signin/", ServerBaseURL];

    NSMutableDictionary *requestParms = [[NSMutableDictionary alloc] init];

//设置参数

    [requestParms setObject:loginName forKey:@"loginname"];

    

    [httpManager POST:url parameters:requestParms

              success:^(AFHTTPRequestOperation *operation, id responseObject) {

//成功

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

//失败

              }];


当前题目:iOSAFNetWorking下同步异步请求
网页URL:http://bzwzjz.com/article/jcgihg.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都品牌网站设计 企业网站设计 成都网站建设 H5网站制作 成都网站建设公司 成都企业网站建设 手机网站制作 盐亭网站设计 成都网站建设 成都网站制作 成都网站设计 成都网站设计 网站建设公司 成都商城网站制作 成都模版网站建设 成都网站设计 成都网站建设 企业网站设计 成都网站建设 做网站设计 app网站建设 成都做网站建设公司