title: How to fix view retain cycle causing subview's dealloc to not be called?
body: <p>I have a view controller which instantiates a bunch of UIButton subclasses and adds them to its self.view and also to a mutable array. These subclasses in turn have a retain property which points to another view. In most cases, the view property points back to the UIButton subclass' superview (the view controller's self.view to which they were added). But not always and not necessarily, which is why I am using this property and not the inherited superview one.</p>
  
  <p>The problem I'm having is that when the view controller's dealloc does:</p>
  
  <pre><code>- (void)dealloc
  {
    [UIBUttonSubClassesArray release];
    [super dealloc];
  }
  </code></pre>
  
  <p>the UIButton subclasses' dealloc is not being called. So the additional release for the view property in these subclasses doesn't get called and, even when the view controller is dealloced, I'm leaking the view controller's view once for each of these UIButton subclasses.</p>
  
  <p>But, if instead I make the subclasses' view property an assign, so that I need not call release in their dealloc, their dealloc does get called and even when there's no code referencing the view now, the app crashes.</p>
  
  <p>Any ideas?</p>