Child class override parent class Property (OC), override class propertyoc

Source: Internet
Author: User

Child class override parent class Property (OC), override class propertyoc
Recently, when I was working on a project, I found a problem about @ property, that is, the problem that the subclass overrides the property of the parent class.

The blogger created a project to test the problem. See Figure ‑

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~

Subclass rewriting (which may be inappropriate for rewriting) attributes of the parent class. If the compiler does not synthesize underlined attributes, You need to manually synthesize setter and getter. Otherwise, this attribute will be implemented by the parent class, at this time, you should Understand the reason (Understand ?).

Because I wrote the set Method in TC1 (the parent class of TC2 ).

Summary: When we need to override the attributes of the parent class in the subclass (which may be slightly inappropriate in rewriting), it is best to hand-Write the set and get methods in the subclass. Otherwise, you can try again.

PS: I heard that Xcode7 has a warning.

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.