成都创新互联网站制作重庆分公司

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下同步异步请求
文章源于:http://cxhlcq.com/article/jcgihg.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部