About the +-symbol before the method
The preceding plus (+) method is a class method, which can be called directly with the class name, and it is primarily a function of creating an instance. Equivalent to a static method.
The preceding minus (-) method is an instance method that must be used by an instance of the class to invoke.
To declare a member variable static, you must use the static keyword
On the parameter problems of the function of Ob-c
A method of object-c can contain more than one parameter, except for the first argument, and all subsequent arguments are written with a name.
How to do multiple parameters
(The data type of the method) function name: (parameter 1 data type) parameter 1 of the numeric value of the first name of parameter 2: (Parameter 2 data type) parameter 2 value name ...;
As an example, the definition of a method:
-(void) Setkids: (NSString *) myoldestkidname secondkid: (NSString *) mysecondoldestkidname thirdkid: (NSString *) MyThird Oldestkidname;
When implementing this function:
-(void) Setkids: (NSString *) myoldestkidname secondkid: (NSString *) mysecondoldestkidname thirdkid: (NSString *) MyThird oldestkidname{
The older son = Myoldestkidname;
two sons = Mysecondoldestkidname;
three sons = Mythirdoldestkidname;
}
When called:
Kids *mykids = [[Kids alloc] init];
[Mykids setkids: @ "Zhang vigorously" secondkid: @ "Zhang Yili" Thirdkid: @ "Zhang Xiao Li"];
And if you write this method in C #, the general wording might be
public void Setkids (string myoldestkidname, String mysecondoldestkidname, String mythirdoldestkidname)
{
...
}
The approximate wording of the call might be:
Kids mykids = new Kids ();
Mykids.setkids ("Zhang vigorously", "Zhang Yili", "Zhang Xiao Li");
Do you understand? It's not really ugly.
Basically, if you can understand the conversion relationship of the following code, your OBJECTIVE-C syntax will understand 80%:
[[[[MyClass alloc] Init:[foo Bar]] autorelease];
The syntax for converting to C # or Java is:
Myclass.alloc (). Init (Foo.bar ()). Autorelease ();
Internet news: A little thing about the internet www.yidin.net
Some Notes on learning iOS development