iOS Code specification:
All code specifications adhere to the Apple SDK principles, not clear please visit the Apple SDK documentation or download the official demo view.
1. Engineering part:
Place the source files for each feature module in the project into the same folder, using the virtual folder.
Referenced. A and related files, stored separately using folders and marked as SDK
2. Class:
Name: Capitalize the first letter, followed by the first letter of each word, and the class file name must match the primary @interface class name in the class. (Example: Rootviewcontroller,personinfo)
Category and protocol can be placed in a standalone file, or before a class.
3. Code:
Variables: All variables are named according to the hump rules, the variable name must be guaranteed to be known as the name, (example: nsstring *personname = @ "123", BOOL isTrue = YES)
In addition, the following conditions must be met:
The temporary variable starts with a lowercase letter, followed by the first letter of each word, and tries not to use numbers and underscores.
Global variables begin with an underscore, prohibit the use of numbers, and 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 attribute 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 parameter description must explicitly describe the following arguments, each of which must represent exactly the function of the parameter, which is strictly forbidden-(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. Annotations, marks
Each of the variables and attributes that are not well-defined must be preceded by a related comment.
Each slightly complex method must be accompanied by a description of the function.
When performing to critical steps, try to use a statement to prompt its action.
Use comment hints when critical process selection occurs.
Additional references appear in the same class, and Mark is added when a standalone function module appears.
Any code that is to be optimized, incomplete, not tested, or indeterminate, needs to be added with Mark.
8, macro, static global variables
Try to write in a separate file.
The short macro commands use uppercase as much as possible, slightly longer to capitalize, followed by lowercase, but with underscores as much as possible.
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.
Common device information, screen size, fixed parameters use macros as far as possible, interface address, path, fixed parameters can use macros or global static variables.
Detailed description of the encoding specification for iOS