title: How to overwrite textDidChange: method correctly?
body: <p>I subclassed NSTextField and overwrite the <b>textDidChange:</b> as:</p>
  
  <pre><code>- (void)textDidChange:(NSNotification *)notification
  {
      // ... My own operation
  }
  </code></pre>
  
  <p>But when I drag a input text box into my <code>.xib</code> file and control drag another class to assign the delegate I found the delegate's <b><code>controlTextDidChange:</code></b> method was never called.</p>
  
  <p>Now tryingto solve this problem, I tried two ways al below: </p>
  
  <p>I. calling <code>super</code>:</p>
  
  <pre><code>- (void)textDidChange:(NSNotification *)notification
  {
      // ... My own operation
      [super textDidChange:notification];
  }
  </code></pre>
  
  <p>But I got an error in runtime: <i>attempt to insert nil object from objects[0]</i></p>
  
  <p>II. calling <code>delegate</code>'s method</p>
  
  <pre><code>- (void)textDidChange:(NSNotification *)notification
  {
      // ... My own operation
      if ([self.delegate responseToSelector:@selector(controlTextDidChange:)])
      {
          [self.delegate ...];    // &lt;--- Opps, something not happerned here.
      }
  }
  </code></pre>
  
  <p>What not happerned? I expected that the auto-complete should display the <code>controlTextDidChange:</code> method at the position of <code>...</code> above. But it did not, actually. I typed the method directly, compilation fail because method not found.</p>
  
  <p>How should I make my sub-class call the delegate normally? How should I overwrite the <code>textDidChange:</code> method correctly?</p>
  
  <hr>
  
  <p>Further question for Vytautas:</p>
  
  <ol>
  <li>I am sure I was using <code>NSTextField</code>. And I set a break point inside controlTextDidChange: method. As it was called, I should have known.</li>
  <li>I did control-drag the text field to the delegate object, and I print delegate object in the <code>textDidChange:</code> method, it was sure that the delegate was set correctly.</li>
  <li>The other delegate methods, such as <code>controlTextDidBeginEditing:</code> were called correctly. But <code>controlTextDidChange:</code> not called</li>
  <li>I tried comment out the over-written in the subclassed <code>NSTextField</code> class, then <code>controlTextDidChange:</code> was called.</li>
  <li>Therefore I was quite sure that I am not overwritting the <code>textDidChange:</code> right. But I do not known how to fix it.</li>
  <li>What made me confused mostly was that why auto-completion did not show the <code>controlTextDidChange:</code> method when I attempted to call it.</li>
  </ol>
  
  <p>About the auto-completion, here is how it showed:</p>
  
  <p><a href="https://i.stack.imgur.com/p5MhO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p5MhO.png" alt=""></a>
  </p>
  
  <p>No <code>- controlTextDidChange:</code> method.</p>
  
  <hr>
  
  <p>2nd further reply for Vytautas:</p>
  
  <p>I tried calling '[self controlTextDidChange]' but it did not work, and error occurred (as highlighted below):
  <a href="https://i.stack.imgur.com/av0yx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/av0yx.png" alt=""></a>
  </p>