I come from the Java world, so to me it’s all object.foo(), but in Objective C, is object messaging the only way to invoke a method?
[object foo];
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.
The first thing that comes to mind is using @property and dot-notation. A class with @property named ‘foo’ allows you to do like this:
which literally translates at compile-time to
(similar with “getters”)
The other ways are more advanced, such as using NSObject’s performSelector: method, or other systems such as NSInvocation, etc. Going deeper, there are ways to call methods in the runtime, with c functions (all of this syntax eventually boils down to calling c-functions anyway); but I’m sure that’s not what you are after.