下载 iPhone 时弹出视图控制器时来自 ASIHTTPRequest 的 exc_bad_access
我有一个自定义导航控制器,所以我制作了自己的后退按钮,
-(void)navigateBack{
[self.navigationController popViewControllerAnimated:YES];
}
并且在视图上确实加载了,我使用 ASINetworkQueue 请求许多图像
-(void)sendRequest:(NSURL *)url withParams:(NSDictionary *)params andSelector:(NSString *)selector{
NSString *jsonString = [params yajl_JSONString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:jsonString forKey:@"json"];
[request setTimeOutSeconds:15];
[[self networkQueue] setDelegate:self];
[[self networkQueue] setRequestDidFinishSelector:NSSelectorFromString(selector)];
[[self networkQueue] setRequestDidFailSelector:@selector(asiRequestFailed:)];
[[self networkQueue] addOperation:request];
[[self networkQueue] go];
}
本质上,每当我发送 HTTP 请求时,我只需执行 [self sendRequest:]。 当我转到这个视图控制器,然后在下载所有图像之前按回键时,我得到一个 EXC_BAD_ACCESS ,它指向 ASIHTTPFormRequest 尝试执行选择器的行。我尝试放入
[networkQueue cancelAllOperations];[self setNetworkQueue:nil];
我的 dealloc 方法,并在此之前和之后放置断点,我可以从 GDB 中看到队列中没有更多请求,但错误不断显示。我错过了什么吗?
谢谢
I have a custom navigation controller so i made my own back button that does
-(void)navigateBack{
[self.navigationController popViewControllerAnimated:YES];
}
and on the view did load, I request for many images using the ASINetworkQueue
-(void)sendRequest:(NSURL *)url withParams:(NSDictionary *)params andSelector:(NSString *)selector{
NSString *jsonString = [params yajl_JSONString];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setPostValue:jsonString forKey:@"json"];
[request setTimeOutSeconds:15];
[[self networkQueue] setDelegate:self];
[[self networkQueue] setRequestDidFinishSelector:NSSelectorFromString(selector)];
[[self networkQueue] setRequestDidFailSelector:@selector(asiRequestFailed:)];
[[self networkQueue] addOperation:request];
[[self networkQueue] go];
}
Essentially, anytime I send an HTTP request, i just do [self sendRequest:].
When I go to this viewcontroller, then press back before all the images are downloading, I get an EXC_BAD_ACCESS that points to the line where ASIHTTPFormRequest tries to perform the selector. I tried putting
[networkQueue cancelAllOperations];[self setNetworkQueue:nil];
in my dealloc method, and i put breakpoints before and after this, and I can see from the GDB that there are no more requests in the queue, but the error keeps showing. Am i missing something?
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代表可能会接到电话通知您取消。您需要删除 dealloc 方法中的所有委托,例如:(
如果您正在使用它们,还需要删除进度委托等)
Your delegates will likely get called to notify you of the cancellation. You need to remove all the delegates in your dealloc method, eg:
(and also progress delegates etc if you're using them)