Search code examples
iosswiftuitextviewdelegate

Cannot assign a value of type 'MyViewController' to a value of type 'UITextFieldDelegate?'


Not sure why I am getting this error (title of this issue is the error as shown in screenshot below) when I try to do self.tv_salaryNumber.delegate = self.

My class EarningsVC does in fact inherit the UITextFieldDelegate protocol, so cant figure out why getting this error. (You can see that on the right most part of hte window under Quick Help too.

enter image description here


Solution

  • Hate to answer my own question but found my (silly) error right after I posted this. I was adding UITextViewDelegate instead of UITextFieldDelegate - so had the wrong delegate.