我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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://mswzjz.cn/article/jcgihg.html

其他资讯