title: Releasing a UIView
body: <p>NB: To clarify what I'm trying to do here:</p>
  
  <p>I have an instance of a subclass of UIView. When this instance gets released from a View Controller I would like that the dealloc method of that instance be called.</p>
  
  <p>The point being to release other objects within that instance of the subclass of UIView.</p>
  
  <p>In the View Controller:</p>
  
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.mav = [[MapAreaView alloc]init];
      [self.view addSubview:self.mav];
      [self.mav release];
  
      t_ = [NSTimer scheduledTimerWithTimeInterval: 20.0f target: self selector:@selector(onTick) userInfo: nil repeats:NO];
  }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>- (void)onTick
  {
      NSLog(@"Releasing...");
      [t_ invalidate];
      t_ = nil;
      [self.mav release];
      [self.mav release];
      [self.mav release];
      NSLog(@"Done releasing.");
  }
  </code></pre>
  
  <p>In MapAreaView:</p>
  
  <pre><code>- (void)dealloc
  {
      NSLog(@"map view area dealloc called.");
      [super dealloc];
  }
  </code></pre>
  
  <p><strong>I am trying to release the MapAreaView and have it's dealloc method called.</strong> </p>
  
  <p>Also, when I run this app, <code>Releasing...</code> and <code>Done releasing.</code> get printed, but not <code>map view area dealloc called</code>. And despite all of my excessive release messages sent to self.mav the app doesn't crash. Weird.</p>
  
  <p>Ideas?</p>
  
  <p><strong>EDIT 1</strong></p>
  
  <pre><code>@interface MemoryManagmentViewController : UIViewController {
  
      MapAreaView *mav_;
      NSTimer *t_;
  }
  
  @property (nonatomic, retain) MapAreaView *mav;
  </code></pre>
  
  <p>which is then synthesized: <code>@synthesize mav = mav_;</code> </p>
  
  <p><strong>EDIT 2</strong></p>
  
  <p>Please not that the timer is not for use in my real application. I'm just using it to learn about memory management. </p>