User Tools

Site Tools



This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ios-labs-s14:basics-methods [2014/02/17 11:22]
ios-labs-s14:basics-methods [2014/02/26 13:02] (current)
Line 2: Line 2:
 “Method”,​ “message”,​ and “function” all (sort of) refer to the same thing in Objective-C. “Method”,​ “message”,​ and “function” all (sort of) refer to the same thing in Objective-C.
-A method is a section of code that we can call from elsewhere in our code.+A method is a section of code that we can execute (callfrom elsewhere in our code.
 Components to methods: Components to methods:
Line 26: Line 26:
 **Definition**- writing the code that executes/is contained within the method. Known as the method body. **Definition**- writing the code that executes/is contained within the method. Known as the method body.
 +Methods are defined in **implementation** files, or //.m// files. The form is the same as the declaration,​ except with curly braces instead of a semicolon which contain the method body. 
-Return TypeA 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.+====Invocation=== 
 +**Invocation**- ​the act of running ​the code contained within a method. ​method ​is invoked on a target, where the target is the object that owns the method.
-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 optionalthat is, a method ​may contain no argument.+Consists of two parts 
 +  -Target- ​the target object ​or class that owns the method; ​where the method ​will be invoked 
 +  -Name- the name of the method to be invoked
-Joining ArgumentA joining argument is to make it easier to read and to make it clear while calling it.+Invoking a method takes the form: 
 +and can be nested infinitely deep: 
-Method Body: The method body contains a collection of statements that define what the method does. +where NAME2 and NAME3 are methods called on the objects returned by methods NAME and NAME2, respectively.
- +
-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.1392657771.txt.gz · Last modified: 2014/02/17 11:22 by mbarboi