我正在使用Xcode 6.1,iOS 8.1中的應用程序;該應用程序工作完全正常,直到2天前,但今天,當我執行它,我得到了一個錯誤的網絡服務&錯誤打印如下。錯誤:錯誤域= NSURLErrorDomain代碼= -1001「請求超時。」
Error: Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x7c6899b0 {NSErrorFailingURLStringKey=, NSErrorFailingURLKey=, NSLocalizedDescription=The request timed out., NSUnderlyingError=0x7c688f60 "The request timed out."}
我用了AFNetworking 2.x和下面的代碼片段,使網絡電話:
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.responseSerializer.acceptableContentTypes=[manager.responseSerializer.acceptableContentTypes setByAddingObject:@"text/html"];
[manager POST:<URL>
parameters:<parameters>
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: %@", responseObject);
NSError *error = nil;
NSDictionary *JSON = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:&error];
if (error) {
NSLog(@"Error serializing %@", error);
}
NSLog(@"Dictionary %@", JSON);
NSLog(@"Success");
}
failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
更新:我做了退出/重新啓動了iOS Simulator.app,reseted內容&設置,但沒有任何工作。
我查過了,我的網絡配置沒變,全過程一樣。我已經完成了我所知道的所有事情,退出/重新啓動iOS Simulator.app,重新設置內容和設置......但沒有工作。 – iYoung