我使用AFNetworking功能和我有一個關於它的問題,我想調用一個不同的功能時,返回值正確AFNetworking - 調用內部
- (AFHTTPRequestOperation *)GET:(NSString *)URLString
parameters:(id)parameters
success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success
failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure
{
AFHTTPRequestOperation *operation = [self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation
*requestOperation, __unused id responseObject) {
if (success) {
int status = [[responseObject objectForKey:@"Status"] intValue];
else if(status == -1)
{
[self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) {
if (success) {
NSLog(@"adfasdfasdfasdf");
success(requestOperation,responseObject);
}
} failure:^(AFHTTPRequestOperation * operation, NSError *error) {
NSLog(@"ERROR: %@", error);
failure(nil, error);
}];
}
else
success(requestOperation,responseObject);
}
} failure:failure];
operation.securityPolicy.allowInvalidCertificates = YES;
operation.securityPolicy.validatesDomainName = NO;
[self.operationQueue addOperation:operation];
return operation;
}
當狀態= -1。我會用上面的參數調用更多的函數,但不能工作。
else if(status == -1)
{
[self HTTPRequestOperationWithHTTPMethod:@"GET" URLString:URLString parameters:parameters success:^(AFHTTPRequestOperation *requestOperation, __unused id responseObject) {
if (success) {
NSLog(@"adfasdfasdfasdf");
success(requestOperation,responseObject);
}
} failure:^(AFHTTPRequestOperation * operation, NSError *error) {
NSLog(@"ERROR: %@", error);
failure(nil, error);
}];
}
運行應用程序和我的bug函數不會調用成功或失敗。
我的意思是,然後status = -1方法「[自我HTTPRequestOperationWithHTTPMethod:@」GET「URLString:URLString」dosen't工作。如何解決它。 – TrungVu
如果條件成功,你首先刪除了嗎?檢查我的代碼,我已經取消了成功的條件。 – ivarun
謝謝ivarun :),我完成了 – TrungVu