iOS 中的 ASIHTTPRequest
我一直在为应用程序使用 ASIHTTPRequest
,但它在 topSecretFetchFailed
method 5 of 10 request 中给我错误,不知道如何处理它,不是 ASIHTTPRequest
够稳定吗?
[request setDidFailSelector:@selector(topSecretFetchFailed:)];
编辑:
这是我在每个请求中调用的代码或方法。 MARKET_INDEXES_URL 其静态字符串,其中包含“someurl.com”;
- (void)requestData {
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:[NSURLURLWithString:MARKET_INDEXES_URL]];
[req setDelegate:self];
[req setDidFailSelector:@selector(topSecretFetchFailed:)];
[req setDidFinishSelector:@selector(topSecretFetchComplete:)];
[self setRequest:req];
[self.request startAsynchronous];
}
这是失败处理程序
- (void)topSecretFetchFailed:(ASIHTTPRequest *)theRequest {
[[NSNotificationCenter defaultCenter] postNotificationName:@"MarketIndexesError" object:nil];
UIAlertView *view = [[UIAlertView alloc] initWithTitle:@"Warning !" message:@"Connection error, Please try again" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[view show];
[view release];
NSLog(@"MarketIndex service Fail: %d %@", [theRequest responseStatusCode], [theRequest responseStatusMessage]);
}
I have been using ASIHTTPRequest
for an application but it gives me error in topSecretFetchFailed
method 5 out of 10 request, Not sure how to deal with it, Isn't ASIHTTPRequest
stable enough?
[request setDidFailSelector:@selector(topSecretFetchFailed:)];
EDIT:
This is my code or method which get called in each request. MARKET_INDEXES_URL its static string which has "someurl.com";
- (void)requestData {
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:[NSURLURLWithString:MARKET_INDEXES_URL]];
[req setDelegate:self];
[req setDidFailSelector:@selector(topSecretFetchFailed:)];
[req setDidFinishSelector:@selector(topSecretFetchComplete:)];
[self setRequest:req];
[self.request startAsynchronous];
}
and this is the fail handler
- (void)topSecretFetchFailed:(ASIHTTPRequest *)theRequest {
[[NSNotificationCenter defaultCenter] postNotificationName:@"MarketIndexesError" object:nil];
UIAlertView *view = [[UIAlertView alloc] initWithTitle:@"Warning !" message:@"Connection error, Please try again" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[view show];
[view release];
NSLog(@"MarketIndex service Fail: %d %@", [theRequest responseStatusCode], [theRequest responseStatusMessage]);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要的是一些响应详细信息的报告。没有它,你就只能在黑暗中进行诊断。将其放入您的故障处理程序中:
What you need is some reporting of the response details. Without that, you're diagnosing in the dark. Put this in your failure handler:
ASIHTTPRequest 稳定。您可能会收到错误,因为您的网络已关闭或您的服务器响应时间过长。
您应该尝试将 ASIHTTPRequest 属性 numberOfTimesToRetryOnTimeout 更改为适合您的内容。
ASIHTTPRequest is stable. You are probably getting error because either your network is down or your server is taking too long to respond.
You should try changing the ASIHTTPRequest property numberOfTimesToRetryOnTimeout to something that suits you.