title: Nil Delegate in Objective C
body: <p>I've read that you should set delegate to nil in <code>dealloc</code>.  I noticed it is doing it in <code>init</code>, is this ok or should you do the same in the <code>dealloc</code>?</p>
  
  <p><strong>"This is subtle one but handy one. If you're passing yourself as a delegate to another object, reset that object's delegate before you dealloc."</strong></p>
  
  <p>file.h  </p>
  
  <pre><code>@interface TestService : NSObject
  {
      NSObject &lt;TestServiceDelegate&gt; *m_delegate;
  }
  
  @property (nonatomic, assign) NSObject &lt;TestServiceDelegate&gt; *delegate;
  </code></pre>
  
  <p>file.m</p>
  
  <pre><code> @synthesize delegate=m_delegate;
  
      - (id)init
      {
          if (self = [super init])
          {        
              m_delegate = nil;
          }
  
          return self;
      }
  
      - (void)dealloc
  
      {
           [super dealloc];
      }
  </code></pre>