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];
Yes. You can use dot syntax to get or set Objective C properties. So for example setting text on a UILabel *label can be done either [label setText:@"some text"];
or label.text = @"some text";
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:
anInstance.foo = @"bar";
which literally translates at compile-time to
[anInstance setFoo:@"bar"];
(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.
For pedantry's sake, why not get low-level:
objc_msgSend(object, sel_getUid("foo"), errVar);