Home » Odeon Blogs » Calvin, Weaver »

Objective C Fundamentals

Objective C Fundamentals

Messaging (method calls)

In Objective C,

  1. [object message]

is equivalent to

  1. object.method()
  2. object->method()

When calling the method with a parameter, i.e. messaging with arguments, we have:

  1. [object message: param1 withParameter: param2]

which of course is equivalent to

  1. object.method(param1, param2)
  2. object->method(param1, param2)

Nested Messaging

  1. [object secondMessage: [object message]]

is equivalent to

  1. object.secondMessage(object.message())
  2. object->secondMessage(object->message())

Import

Importing is the inclusion of the source code of a specified file within the current file:

  1. #import "Class.h"
  2. #import <Class.h>
  3. #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

  1. 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 :

(required)


(required)




(required)




(required)






Leave a Comment


Page generated in: 0.16s