User Tools

Site Tools


ios-labs-s14:basics-methods

This is an old revision of the document!


A PCRE internal error occured. This might be caused by a faulty plugin

The terms “method”, “messages”, and “function” all kind of refer to the same thing in Objective-C. You may hear them used interchangeably, though there are differences. I will stick with the terminology “calling a method” in this post. A method (or message or function) is a section of code that we can call from elsewhere in our code, and the method will perform some action or return some kind of result that we can use. Methods are used to organize our code into reusable (and understandable) chunks that save us a lot of time and energy. A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function. A method definition in Objective-C programming language consists of a method header and a method body. Here are all the parts of a method: Defining a Method Return Type: A method may return a value. The return_type is the data type of the value the function returns. Some methods perform the desired operations without returning a value. In this case, the return_type is the keyword void. Method Name: This is the actual name of the method. The method name and the parameter list together constitute the method signature. Arguments: A argument is like a placeholder. When a function is invoked, you pass a value to the argument. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the arguments of a method. Arguments are optional; that is, a method may contain no argument. Joining Argument: A joining argument is to make it easier to read and to make it clear while calling it. Method Body: The method body contains a collection of statements that define what the method does. Declaration Method declaration is required when you define a method in one source file and you call that method in another file. In such case you should declare the function at the top of the file calling the function.

ios-labs-s14/basics-methods.1392346369.txt.gz · Last modified: 2014/02/13 20:52 by mbarboi