I'm confused as to what a 'receiver' is in Objective-C?
On the follwing site is says the following about what a receiver is: https://quizlet.com/104540068/objective-c-flash-cards/
"In Objective-C, you specify the object (known as the receiver of the method) and the message being sent to that object by enclosing the message expression in brackets."
I don't understand this. I'm very new to Objective C. Any help is appreciated. Thanks.
In Objective-C, a message is sent to a receiver.
The message is the method you are calling. The receiver is the what the message is called on.
Example. Let's say you have an NSString
:
NSString *str = @"Hello";
Now you want to get the length of the string. You send the length
message to str
. str
is the receiver of the message:
NSInteger len = [str length];
Basically, the receiver is the part on the left inside the square brackets and the message is the part on the right in the square brackets.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With