I have an ImageDownloader class with NSURLConnection* connection as an ivar which initializes it setting its delegate as self. Now the doubt is when I init an ImageDownloader instance in my AsyncImageView so that my image downloading is started it has a retain count =2 {1 with image downloader init and 2 with nsurl init setting delegate as self}. So when i release image downloader from my asyncImageView it still has a retain count =1开发者_如何学运维.
How do I release the imageDownloader instance because there is probably a leak? If I release connection ivar in imageDownloader the retain count should be 0 but then the app crashes(for obv. reasons).
Yes, NSURLConnection instance retains its delegate. So you should call [connection cancel] to release it before releasing ImageDownloader instance.
精彩评论