After writing the class declaration and implementation, how can an application call it?
In objective-C, the simple format of calling a method is as follows:
(1) [instance method];
For example, [person setage: 32]; // Where person is an instance of the person class.
Or:
(2) [Class Name and method name];
For example, nsstring STR = [nsdate date]; // you can call the date method in the nsdate class to obtain the current date and time.
In objective-C, calling a class or instance method is also called to send a message to this class or instance ). Class instance is called "receiver ". Therefore, the general method call format can also be understood:
[Receiver message];
In terms of terms, the entire expression is also called a message expression. This is the official name.
Of course, a method may have parameters or multiple parameters. Therefore, the complete method call format is as follows:
[Receiving Method Name 1: parameter 1 name 2: parameter 2 Name 3: parameter...];
For example:
[Person setage: 32];
[Person setname: @ "Sam" andsencondname: @ "job"];
Note: The method names starting from the second can be omitted when multiple parameter methods are called.
For example:
[Person setname: @ "Sam": @ "job"];
You can call another method in a method. For example:
[Nsstring stringwithformat: [test format];
Note: To call a method, you must add the brackets "[...]".
Refer:
1. Call the objective-C method
Http://blog.csdn.net/ztp800201/article/details/7678125
(Conversion) Objective-C method call