iOS Development Summary (A0)-Class, variable, enum, method naming conventions and good practices

Source: Internet
Author: User

Reference effective Objective 2.0 item use clear and consistent naming recommendations

1. Method Name: Apply the Hump nomenclature, methods name should be able to show how the method is doing, do not worry about the name process, because when used, Xcode will automatically complete

-If methods returns a value, the method name should indicate what the value

-Do not use abbreviations

-For Boolean property, plus is or has prefix

-Do not use the Get prefix

-The name should be easy to read, as much as a natural sentence

2. Class protocol Name:

Use camel-named (each logical breakpoint in the name has a size letter identifier), and add a prefix that should reflect the company or individual, or the app itself, the first letter should be capitalized in order to distinguish it from variables and method

such as Beddupmycustomclass

3. Classes, methods, protocols, and other naming should be consistent in app development

In fact, the Objective-c method, class, protocol, etc. of the multi-reference standard is named, and it will keep the same style for a long time.

4. Instance variable, the name of the property, shall indicate what the property is,

(unless it's clear what it is (like scores, it's obviously an array, you don't have to name it Scorearray)

If it is a uilabel, it should be named ***label, if it is uiimageview, it should be ***imageview.

?

Add prefix K for # define

For private methods (not the public API), add a prefix that distinguishes it from the public API (such as adding p, or p_ is good)

?

iOS Development Summary (A0)-Class, variable, enum, method naming conventions and good practices

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.