iOS Coding Specifications Specific Instructions

Source: Internet
Author: User

iOS Code specification:

All code specifications follow the Apple SDK principles, not clear please visit the Apple SDK documentation or download the official demo view.


1. Project section:

Place the corresponding source files for each functional module in the project into the same directory, using the virtual directory.

Referenced. A and related files. Separate use of directory storage. and indicated that it is the SDK


2. Class:

Name: Capitalize the first letter, then capitalize the first letter of each word, and the name of the class file must match the basic @interface class name in the class. (Example: Rootviewcontroller. PersonInfo)

Category and protocol can be placed in separate files, or before a class.


3. Code:

Variables: All variables are named according to the hump rules, variable names must be guaranteed to be known. (example: NSString *personname = @ "123", BOOL isTrue = YES)

In addition, the following conditions must be met:

The temporary variable starts with a lowercase letter. Each of the following words is capitalized in the first letter, as far as possible without using numbers and underscores.

The global variable starts with an underscore. Use no numbers, try not to underline in the middle.

4. Data type:

Use the OBJECTIVE-C data type and use the OBJECTIVE-C data type to avoid cross-use (even if you know it is a type).


5. Properties, Methods

All property names cannot begin with an underscore, try not to use the word shorthand. Cases

@property (Nonatomic,strong) NSString *ordernumber;

@property (Nonatomic,strong) nsmutabledictionary *studentinfo;

The method name must begin with a lowercase letter, each of which describes the parameters that must be understood in the descriptive narrative, each of which must be an exact representation of the role of the parameter. It is forbidden to appear-(ID) init: (NSString *) a B: (NSString *) b as the method name for this class.


6. Statements, parentheses

All statements must follow the left alignment principle, and the parentheses should be consistent.

Note Alignment before line breaks, line breaks in nested statements, and parentheses must be indented in turn.

7. Gaze, Mark

Before each of the variables and attributes that are not clear enough. Must be added to the relevant gaze.

Every slightly more complex approach. A descriptive narrative of the function must be added.

When you run to the critical step. Try to use a statement to prompt its action.

Use gaze hints when critical process choices occur.

Other references appear in the same class. When a standalone function module appears. Join Mark.

Arbitrarily optimized, not intact, not tested, indeterminate code. Need to join Mark.

8, macro, static global variables

Try to write in a separate file.

Short macro commands use uppercase as much as possible, slightly longer to capitalize, and then lowercase, but try to differentiate them with underscores.

A large number of reused values use macros as much as possible, with too many nested layers, high frequency, and fixed formatting without the need for large changes.

Often use the device information, screen size, fixed parameters to use the macro as far as possible, interface address, path, fixed parameters can use macros or global static variables.

iOS Coding Specifications Specific Instructions

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.