title: Problem releasing object using "removeFromSuperView" iPhone
body: <p>I have this concrete problem, but if You find my initial design idea crazy and have a better suggestion, please let me know:)</p>
  
  <p>I have a UIView that acts as a container/background for adding other views. The important thing is that only one view is present at a time. So before doing any adding of views I do this:</p>
  
  <pre><code>        for(UIView *v in [self.currentView subviews]) {
  
          [v removeFromSuperview];
      }
  </code></pre>
  
  <p>self.currentView is the view I add my subviews to.</p>
  
  <p>After this I add a new UIView in this manner:</p>
  
  <pre><code>        UIView *tempView;
  
      switch (self.currentIndex) {
          case 1:
              tempView = [[AView alloc] initWithFrame:frame];
              [self.currentView addSubview:tempView];
              [tempView release];
              break;
          case 2:
              tempView = [[AView alloc] initWithFrame:frame];
              [self.currentView addSubview:tempView];
              [tempView release];
              break;
          default:
              break;
      }
  </code></pre>
  
  <p>This way I remove all views, since I release the tempView straight after I add it to
  the self.currentView I end up with a retain count of one on the the UIView currently living 
  in the currentView.</p>
  
  <p>This all seems fine, but as I look at it with Instruments I can see that each time I run the above code a new AView object is allocated and the old one keeps hanging around with a retain count of 1, either I am missing some obvious retain action being performed on my object or else the "removeFromSuperView" does not call "release" on my view.</p>
  
  <p>In real life my objects are not of type AView, but of many different types, but this way I can test if there is always only one AView instance allocated.</p>
  
  <p>As I can read from the documentation "removeFromSuperView" should call "release" on the view so I am a bit confused as to why my Views are not deallocated.</p>
  
  <p>Again, maybe I am going about this the wrong way and suggestions are really welcome.
  The setup is that there is a number of button at the bottom of the screen and when the user clicks on the view changes.</p>
  
  <p>Thanks for any help or <em>pointers</em> given:)</p>