iOS Programming (Fourth Edition) Notes--to be continued

Source: Internet
Author: User

1, Party *partyinstance = [Party alloc]; [Partyinstance Init]; Because any object must be created and initialized before it can be used, the above two messages should be written in one line of code, with the following code:

party *partyinstance = [[Party alloc] init];

This practice of writing two messages together in a single line of code is called nested message sending (nested messages send). The program executes the code in the innermost square brackets first, so the party class receives the ALLOC message first. The Alloc method then returns a pointer to the newly created object. Finally, the uninitialized object receives the INIT message, returns the initialized object pointer, and saves the pointer in the variable.

---------------------------------------------------------------------------------------------------------

2, tags and parameters must be paired with the syntax is an important feature of objective-c. In other languages, this line of code might be written as:

Partyinstance.addattendeewithdish (Someperson, Deviledeggs);

In these languages, the individual values of the incoming function correspond to which parameters are not obvious. In Objective-c, each value will be paired with the corresponding tag, with the following code:

[Partyinstance Addattendee:someperson Withdish:deviledeggs];

Remember here that each set of square brackets corresponds to only one message that needs to be sent. Although the addattendee:withdish here: there are two tags, but still only a message, sending this message will only trigger a method.

--------------------------------------------------------------------------------------------------------

3

iOS Programming (Fourth Edition) Notes--to be continued

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.