我我使用AFNetworking Framework来调用API,有时在API调用时我没有从服务器得到任何响应:
这是我的代码段:
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];
[manager.requestSerializer setTimeoutInterval:timeOutInterval];
[manager POST:[NSString stringWithFormat:@"%@%@",MainUrl,apiName] parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSArray *arrData = responseObject;
NSLog(@"%@",arrData);
NSString *strCode = [NSString stringWithFormat:@"%@",[arrData valueForKey:@"success"]];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
[SVProgressHUD dismiss];
NSLog(@"Error: %@", manager);
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"Message" message:@"Please check your internet connection" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}];
我得到以下错误:
Error: <AFHTTPRequestOperationManager: 0x80010ce0, baseURL: (null), operationQueue: <NSOperationQueue: 0x80010ca0>{name = 'NSOperationQueue 0x80010ca0'}>
任何帮助将不胜感激。
在ios 9.1中 AFNetworking 2.5