Take notes on ios development and take notes on ios development
+-Symbol before the Method
The method of the plus sign (+) is a class method, which can be called directly by class name. Its function is mainly to create an instance. It is equivalent to a static method.
The method of minus sign (-) is an instance method, which can be called only by using an instance of the class.
To declare a member variable as static, the static keyword must be used.
Questions about the parameters of Ob-c Functions
A Method of Object-c can contain multiple parameters. Except for the first parameter, all subsequent parameters must be named.
Writing multiple parameters
(Method data type) function name: (parameter 1 data type) value of parameter 1 Name of parameter 2 Name: (parameter 2 data type) Name of parameter 2 value .... ;
For example, the definition of a method:
-(Void) setKids: (NSString *) myOldestKidName secondKid: (NSString *) mySecondOldestKidName thirdKid: (NSString *) myThirdOldestKidName;
When implementing this function:
-(Void) setKids: (NSString *) myOldestKidName secondKid: (NSString *) mySecondOldestKidName thirdKid: (NSString *) myThirdOldestKidName {
Eldest Son = myOldestKidName;
Second son = mySecondOldestKidName;
Son 3 = myThirdOldestKidName;
}
When calling:
Kids * myKids = [[Kids alloc] init];
[MyKids setKids: @ "" secondKid: @ "" thirdKid: @ ""];
However, if you use c # To write this method, the general statement may be:
Public void setKids (string myOldestKidName, string mySecondOldestKidName, string myThirdOldestKidName)
{
...
}
The calling method may be as follows:
Kids myKids = new Kids ();
MyKids. setKids ("Zhang Dali", "Zhang erli", and "Zhang Xiaoli ");
Do you understand? In fact, it is not difficult to understand.
Basically, if you can understand the Conversion Relationship of the following code, your Objective-C syntax can be roughly achieved:
[[MyClass alloc] init: [foo bar] autorelease];
The syntax for converting to C # or Java is:
MyClass. alloc (). init (foo. bar (). autorelease ();
Internet Information: Something about the Internet: www.yidin.net