ASIHTTPRequest,EXC

编程入门 行业动态 更新时间:2024-10-18 03:22:43
本文介绍了ASIHTTPRequest,EXC_BAD_ACCESS请求完成后的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试使用ASIHTTPRequest执行异步请求,但在请求完成时收到通知时有一些问题。

I'm trying to do an asynchronous request with ASIHTTPRequest, but have some problem getting notified when the request is done.

-(void)doDownload{ NSURL *url = [NSURL URLWithString:@"www.someurl/?"]; ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url]; [request setPostValue:@"someValue" forKey:@"someField"]; [request setRequestMethod:@"POST"]; [request setDelegate:self]; [request setDidFinishSelector:@selector(requestFinished)]; [request startAsynchronous]; } - (void)requestFinished:(ASIHTTPRequest *)request { // Use when fetching text data NSString *responseString = [request responseString]; }

requestFinished永远不会被调用。我在ASIHTTPRequest.m中得到一个异常,-handleStreamCompleted:

requestFinished is never called. I get an exception in ASIHTTPRequest.m, -handleStreamCompleted:

if (fileError) { [self failWithError:fileError]; } else { [self requestFinished]; <----- this call fails }

任何线索?

推荐答案

你确定你的类实现 - (void)requestFinished:(ASIHTTPRequest *)请求仍然在请求完成时?看起来像我的班级得到释放太​​早。请注意,委托属性不保留其内容。

Are you sure that your class that implements - (void)requestFinished:(ASIHTTPRequest *)request is still there when the request finishes? It looks to me like the class gets deallocated too early. Note that the delegate property does not retain its content.

您可以添加 [自我保留] to doDownload 和 [self release] to - (void)requestFinished :( ASIHTTPRequest *)请求,但请确保(!) [self release] 也不会调用经常。如果请求永远不会完成,这也可能是内存泄漏。最好保留你的课程在其他地方。

You could add a [self retain] to doDownload and a [self release] to - (void)requestFinished:(ASIHTTPRequest *)request, but make sure (!) that [self release] doesn't get called too often. This is also a possible memory leak if a request would never finish. It would be best to retain your class somewhere else.

您也可以尝试使用 NSZombieEnabled 设置为 YES 找到错误。

You might also try to debug with NSZombieEnabled set to YES to find the error.

更多推荐

ASIHTTPRequest,EXC

本文发布于:2023-11-14 09:48:32,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1586887.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:ASIHTTPRequest   EXC

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!