I have a custom UIView called TiledImage which has a single property named tiledImage and a custom drawRect method. I add this view to my ViewController, but when the ViewController is deallocated the dealloc for this view is never being called, even though I am releasing the view and setting it to nil. What could be causing this? I don't have any other references to the view, so my understanding is that it should release correctly.
This is how I add the view to my view controller:
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"tile" ofType:@"png"];
UIImage *image = [[UIImage alloc] initWithContentsOfFile:imagePath];
self.backImageView = [[TiledImage alloc] initWithFrame:IMAGE_FRAME];
self.backImageView.tiledImage = image;
[self.view addSubview:self.backImageView];
[self.view sendSubviewToBack:self.backImageView];
[image release];
And in my ViewController's dealloc method I have this:
_backImageView.tiledImage = nil, [_backImageView release], _backImageView = nil;
That line of code is hit, but dealloc is never called on TiledView. Note that _backImageView is the var that the property backImageView uses.
Can someone give me ideas on what I may be doing wrong that is preventing the dealloc on the TiledImage object from being called?