EZ

Eduzan

Learning Hub

Eduzan
Eduzan / Objective C

Objective C Functions

In Objective-C, functions are defined outside of any class or method and can be called from anywhere in the program where they are visible. Functions can accept parameters and return values.

Defining Functions

A function definition includes the return type, function name, and parameters (if any).

// Function definition
int add(int a, int b) {
    return a + b;
}

Calling a Function

To call a function, simply use its name followed by arguments in parentheses.

// Function call
int result = add(5, 3);  // result is 8
NSLog(@"The result is %d", result);
End of lesson.