The bits and pieces that iOS needs to use

Source: Internet
Author: User

Some things, although not important, but bits and pieces will be used, just make a statement:

There are 2 keywords in the protocol that control whether the method is implemented (by default, @required) and, in most cases, the communication between programmers @required: This method must be implemented (if not implemented, the compiler warns)@required- (void)test; - (void)test2; @optional: This method is not necessarily implemented

@optional

- (void)test3;

The semantics of @synthesize is that if you do not implement setter methods and Getter methods manually, then the compiler will automatically add these two methods to you.

@dynamic tells the compiler that the setter and getter methods of the properties are implemented by the user themselves and are not generated automatically. (Of course, for ReadOnly properties, only getter is required). If a property is declared as @dynamic var and then you do not provide @setter method and @getter method, it is not a problem to compile, but when the program runs instance.var = someVar , the program crashes due to the lack of setter method, or when run to someVar = var , due to lack of get The TER method can also cause crashes. Compile-time is no problem, the runtime executes the corresponding method, which is called dynamic binding.

The bits and pieces that iOS needs to use

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.