20th: Prefix the private method name

Source: Internet
Author: User

The private method name plus some prefixes,

1, help debugging;

2, it is easy to distinguish between public and private methods (that is, easy to distinguish which methods are easy to change, which are not easy to change.) )。

Objective-c language There is no way to label a method private.

Each object can respond to any message (see 12), and it can view the messages that an object can respond to at run time (see article 14). Based on the given message, the corresponding method is identified, which is to be completed at run time (see article 11) (Objective-c language Dynamics , dynamic method distribution System Dispatch System)).

"P_" is the prefix for the private method name.

Do not prefix a private method with an underscore, as this is reserved for Apple.

Example:-(void) _resetviecontroller is the private method of Apple Uiviewcontroller, which resets all the States in the controller.
If you overwrite in a subclass, then the parent class will never execute, so the behavior of this view controller will be strange, and you may wonder why the methods of subclasses are called so frequently.

20th: Prefix the private method name

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.