Quote:
Originally Posted by Stratis
Hi, can someone help me out with function declaration in Objective-C? I've looked for other resources but they don't really explain how to declare parameters. Could someone post an example like (for C):
void foo(int a, int b, char c)
void is the function type, foo is the function name. The three parameters are a, b, and c, with a and b being ints and c being a char.
Thanks.
|
In objective C, there are instance methods and class methods. Instance methods are methods that are invoked by sending a message to an INSTANCE of an object. Then there are class methods. Class methods are sent to the whole class, not to an instance of a class.
The declaration of instance methods starts with a dash ("-") Class methods start with a plus sign ("+").
The type of the result is next, in parenthesis.
Parameters are named in Objective C. An objective C version of your foo method might look like this:
Code:
- (void) foo: (int) parameter1 paramName2: (int) parmeter2;
EDIT: Do a google search on "Objective C reference" and download the PDF file that comes up. That's a long article documenting Objective C.