a scenario is below.
I made two Controllers, A tableViewController, B viewController and C ScrollView. A tableViewController has cell that is entering to B viewController. and B viewController has C scrollView that is B's front View.
C scrollView has object of NSURLConnection. and this functioned to download an image.
( A -> pushViewController -> B (has C) -> (C process NSURLConnection after initiation))
If I dismiss the C scrollView during downloading an image, occur an Error !! (after finishing download) Because when B scrollViewController is dismissed, object of C is released. So, after connection 'didFinished', not search C delegate (after calling didFinished, process B object method.)
here is a part of C's code.
- (void)downloadScreenshotWithURLString:(NSString *)aURLString {
AsyncImageViewDownload* download; // AsyncImageViewDownload has NSURLConnection
download = [[AsyncImageViewDownload alloc] initWithURL:aURLString delegate:self selector:@selector(urlDownload:data:error:)];
[[self operationQueue] addOperation:download];
[download release];
}
// After download.
- (void)urlDownload:(AsyncImageView *)aDownload data:(NSData *)data error:(NSError *)error {
if (data)
{
// add ImageData to the front view.
[self displayScreenshot:data];
}
else
{
NSLog(@"download error: %@", error);
}
}
and dealloc method of B is here.
- (void)dealloc {
[C release];
C = nil;
[super dealloc];
}
How can't I occur an Error?? Please help me...