Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does obj.delegate=self mean?

What does it actually mean to set the delegate of a textfield?

For example: txtField.delegate = self

like image 455
devaditya Avatar asked May 08 '26 22:05

devaditya


1 Answers

"In short, that you are receiving calls from the txtField. You are setting the object 'self' as the delegate for txtField."

"That means that your 'txtField' will receive events from itself

These two answers essentially mean the same thing. But seemingly contradictory. But the first makes more sense to me. I can see why a beginner gets confused, I've been there!

Basically one is the caller one is the receiver Think of it as a chef in a kitchen call his assistant to cut up some onions. In this particular case, txtField is the chef, "self" is the assistant. txtField orders self "Do this, this and this!" Like it or not the assistant has to oblige cuz he has wife and kids to feed. :)

like image 70
Rich4321 Avatar answered May 11 '26 11:05

Rich4321



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!