everywhere they say what IBAction is but do not explain what the whole declaration means.
What is sender and id?
Regards,
Namratha
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
According to my knowledge
IBActionjust impliesvoididis a generic C type, which accepts objects of any kind/class. It is some what similar to void pointer inC. We can useidas a parameter of a method, in case, if objects of difference kind of classes will access that method.sender, here,changeGreeting:An Example:
Lets assume the method
changeGreeting:is defined inClassA, and it reads like the following.And consider we have the following lines in
Class B.In LINE 1,
aLabelis the sender andobjOfClassAis the receiver. And in LINE 2:aTextFieldis the sender andobjOfClassAis the receiver. HereaLabel&aTextFieldare called senders because they are calling the methodchangeGreeting:. AndobjOfClassAis called receiver becauseobjOfClassA'schangeGreeting:method is called here.When the user touches inside the
aLabeloraTextField, theirtextwill be changed toHello UILabelorHello UITextFieldrespectively.The other Way:
We can also call
changeGreeting:method ofobjOfClassAfromClass Blike the following.As the above code is self explanatory,
objOfClassAis the receiver. ButaLabel&aTextFieldare not the senders. Because they are not invoking the method. Here they are just the arguments. Here the actual sender isClass B, butaLabelandaTextFieldare passed in the argument(id)sender. Either way the result of the method execution is same.