title: Counting number of characters using textViewDidChange in ios
body: <p>I have search this problem every where but i am not getting my result.
  I have set textview as delegate.
  I want to display the number of count in label "counter" 
  Can anyone tell me what is wrong with my code?</p>
  
  <pre><code>- (void)textViewDidChange:(UITextView *)textView
  {  
      NSString *substring = [NSString stringWithString:textView.text];
      //if message has text show label and update with number of characters using the NSString.length function
      if (substring.length &gt; 0) {
             self.counter.hidden = NO;
          self.counter.text= [NSString stringWithFormat:@"%d characters", substring.length];   
      }
      //if message has no text hide label
      if (substring.length == 0) {
          self.counter.hidden = YES;
      self.counter.text= [NSString stringWithFormat:@"%d characters", substring.length];
      }
  }
  </code></pre>