且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASIHTTPRequest, EXC_BAD_ACCESS 当请求完成时

更新时间:2023-11-20 23:28:22

你确定你的实现 - (void)requestFinished:(ASIHTTPRequest *)request 的类在请求完成时还在那里?在我看来,该类过早地被解除分配.请注意,delegate 属性不保留其内容.

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.

您可以在 doDownload 中添加一个 [self retain],在 - (void)requestFinished 中添加一个 [self release]:(ASIHTTPRequest *)request,但要确保 (!) [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.