iOS 中的 ASIHTTPRequest

发布于 2024-11-07 21:05:44 字数 1244 浏览 1 评论 0原文

我一直在为应用程序使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

若无相欠,怎会相见 2024-11-14 21:05:44

您需要的是一些响应详细信息的报告。没有它,你就只能在黑暗中进行诊断。将其放入您的故障处理程序中:

NSLog(@"Fail: %d %@", [request responseStatusCode], [request responseStatusMessage]);

What you need is some reporting of the response details. Without that, you're diagnosing in the dark. Put this in your failure handler:

NSLog(@"Fail: %d %@", [request responseStatusCode], [request responseStatusMessage]);
找回味觉 2024-11-14 21:05:44

ASIHTTPRequest 稳定。您可能会收到错误,因为您的网络已关闭或您的服务器响应时间过长。

您应该尝试将 ASIHTTPRequest 属性 numberOfTimesToRetryOnTimeout 更改为适合您的内容。

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:....
request.numberOfTimesToRetryOnTimeout=10;

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.

ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:....
request.numberOfTimesToRetryOnTimeout=10;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文