我一直在为我的所有 Http Request 使用 AFNetworking 库,我的示例请求如下所示
AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc] initWithRequest:requestObj];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
[dic setValue:operation forKey:@"operationObj"];
[dic setValue:responseObject forKey:@"jsonData"];
[requestedView performSelector:callBackFunction withObject:[NSNumber numberWithBool:YES] withObject:dic];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error resopnse => %@",error);
[dic setValue:operation forKey:@"operationObj"];
[dic setValue:error forKey:@"error"];
[requestedView performSelector:callBackFunction withObject:[NSNumber numberWithBool:YES] withObject:dic];
}];
当我第一次发出 Http 请求时,操作队列需要很长时间才能启动,有时我会导致 0 作为响应状态代码,
但是一旦我尝试再次触发相同的请求,我就没有遇到任何问题。
我错过了什么吗?
提前致谢