-1

私はすべての 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 になることがあります

しかし、同じリクエストを再度トリガーしようとすると、問題は発生しませんでした。

私は何かを逃していますか?

前もって感謝します

4

1 に答える 1

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]見えない下に呼び出しがありますか?

于 2013-01-04T16:00:38.153 に答える