2

I'm looking at code in a UIViewController that conforms to the UITextViewDelegate protocol and has an instance variable called someTextView.

someTextView.text = @"some text";
[self textViewDidChange:someTextView];

Is that safe? That doesn't look Kosher to me. Is it even necessary to call textViewDidChange:? Won't it get called automatically by someTextView.text = @"some text"?

I'm debugging this error iPhone Objective-C: Keyboard won't hide with resignFirstResponder, sometimes

Community
  • 1
  • 1
ma11hew28
  • 121,420
  • 116
  • 450
  • 651

1 Answers1

7

read the discussion of textViewDidChange:

Discussion

The text view calls this method in response to user-initiated changes to the text. This method is not called in response to programmatically initiated changes.

If it's safe and a good idea to call (UIView-) delegate methods manually depends on the code inside of the method. Sometimes there are valid reasons to do this.

But your bug is most likely not caused by this snippet.

Community
  • 1
  • 1
Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247