Objective C Fundamentals
Messaging (method calls)
In Objective C,
- [object message]
is equivalent to
- object.method()
- object->method()
When calling the method with a parameter, i.e. messaging with arguments, we have:
- [object message: param1 withParameter: param2]
which of course is equivalent to
- object.method(param1, param2)
- object->method(param1, param2)
Nested Messaging
- [object secondMessage: [object message]]
is equivalent to
- object.secondMessage(object.message())
- object->secondMessage(object->message())
Import
Importing is the inclusion of the source code of a specified file within the current file:
- #import "Class.h"
- #import <Class.h>
- #import <director/Class.h>
Method Headers
The first line of a method, the return type, method name and parameters are stated in the method headers.
Category: Objective C



Discussion
Actually, [foo bar] in Objective-C is the equivalent of foo->bar() in C++. If you have params, then it's [foo bar: arg] and foo->bar(arg) respectively.
Leave a Comment :
Leave a Comment