I thought ASIHTTPRequest will retain it for asynchronous request, because this problem doesn't happen when running in the simulator.
anyway, I have changed the code by following your suggestion but I still get the same problem.
If I comment out the two release in requestFailed and requestFinished, there is no EXE_BAD_ACCESS. So if I need to retain the request object, where shall I release it?
some logs might help
2010-01-25 13:24:04.540 TestWebView[151:207] request starting
2010-01-25 13:24:06.014 TestWebView[151:207] requestFinished
2010-01-25 13:24:07.898 TestWebView[151:207] request starting
2010-01-25 13:24:09.296 TestWebView[151:207] requestFinished
2010-01-25 13:24:16.294 TestWebView[151:207] request caceling
2010-01-25 13:24:18.342 TestWebView[151:207] request caceling
2010-01-25 13:24:21.261 TestWebView[151:207] request starting
2010-01-25 13:24:21.613 TestWebView[151:207] request caceling
2010-01-25 13:24:21.643 TestWebView[151:207] request Error=Error Domain=ASIHTTPRequestErrorDomain Code=4 UserInfo=0x13c2b0 "The request was cancelled"
Program received signal: “EXC_BAD_ACCESS”.
also, thanks for the nil tips
-(IBAction)request1{
NSLog(@"request starting");
[self sendRequest];
}
-(IBAction)cancel1{
NSLog(@"request caceling");
[asiRequest cancel];
}
-(void)sendRequest{
asiRequest=[[ASIHTTPRequest requestWithURL:[NSURL URLWithString:@"http://maps.google.com/"]] retain];
[asiRequest setDelegate:self];
[asiRequest startAsynchronous];
}
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"requestFinished");
[asiRequest release];
asiRequest=nil;
}
- (void)requestFailed:(ASIHTTPRequest *)request
{
NSLog(@"request Error=%@",[request error]);
[asiRequest release];
asiRequest=nil;
}