Objective c 第一个请求占用很长时间的AFN网络队列

Objective c 第一个请求占用很长时间的AFN网络队列,objective-c,ios,afnetworking,Objective C,Ios,Afnetworking,我一直在使用AFNetworking库处理所有Http请求,我的示例请求如下所示 AFJSONRequestOperation *operation = [[AFJSONRequestOperation alloc] initWithRequest:requestObj]; [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {

我一直在使用AFNetworking库处理所有Http请求,我的示例请求如下所示

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作为响应状态代码

但是,一旦我尝试再次触发相同的请求,我就不会面临任何问题

我错过什么了吗


提前感谢

我不确定您的请求是什么,但完成和成功块会影响请求的开始时间。我通常使用
AFJSONRequestOperation
s,如下所示:

AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
    // Success
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
    // Failure
}];

[operation start];

是否有一个我们看不到的
[operation start]
调用?

ya我有[operation start];在成功和失败阻塞之后,我的问题是每个第一个请求都会花费更多的时间,有时请求本身会计时out@Ramesh你连接到哪台服务器?谷歌应用程序引擎,我不认为它的服务器请求是定时的out@Ramesh你找到问题了吗?是的,我找到了,但忘了在这里发表评论,这是Google app engine前端实例问题,如果没有请求,Google app engine将自动关闭其前端实例(在特定时间),因此,一旦出现新请求,启动新实例需要时间,这导致了延迟。这不是AFN网络的问题!!!谢谢你对这篇文章感兴趣