Take notes on ios development and take notes on ios development

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.