title: When to release objects in a Tab bar application?
body: <p>This is an extension to my question <a href="https://stackoverflow.com/questions/5786862/xcode-4-tab-bar-application-problem-in-executing-third-tab">here</a></p>
  
  <p>Here is the scenario:</p>
  
  <p>I have three tabs in which a switch is there. When I touch the switch, a label gets updated (ON or OFF) and image of a bulb changes from one jpg to another. So I am using UIImageView in which I am changing the UIImage.</p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  @interface FirstViewController : UIViewController {
      UISwitch *switch1;
      UILabel *status1;
  }
  
  @property (nonatomic,retain) IBOutlet UISwitch *switch1;
  @property (nonatomic,retain) IBOutlet UILabel *status1;
  - (IBAction) switch1Change;
  @end
  </code></pre>
  
  <p>and the implementation is</p>
  
  <pre><code>#import "FirstViewController.h"
  @implementation FirstViewController
  @synthesize switch1;
  @synthesize status1;
  - (IBAction) switch1Change
  {
      if (switch1.on) {
          status1.text = @"ON";
          ...
      }
      else {
          status1.text = @"OFF";
          ...
      }
  }
  </code></pre>
  
  <p>I am not able to understand when to release the objects. I tried giving the [switch1 release] in - (void) dealloc {} method. But when I switch tabs, the app crashes. How to do this?</p>