Naming specification class naming
- Capitalize the first letter, then capitalize the first letter of each word
- Use a noun phrase that reflects the function of the class
- File and class have the same name
Special class naming
- If the subclass of the view controller should be added with the suffix "viewcontroller" or "Controller", add "Board_iphone" in Beeframwork. Beeuiboard in Beeframework inherits from "Viewcontroller".
- If the subclass of the view should be added suffix "view"
- If it is a child of the button, the suffix "button" should be added
Classification (category) naming
Same as the class name, plus the class name to extend and the "+"
Example: nsstring+urlencoding
Protocol (delegate) naming
Same as class naming, plus add "Delegate" suffix
Example: Myviewdelegate
Method naming
- The first letter is lowercase and the first letter of each word is capitalized
- Method names use verb phrases
Example:-(void) Setpostvalue: (int) value
Method parameter naming
- The first letter is lowercase and the first letter of each word is capitalized
- have sufficient explanatory
- No need to add type prefixes
Example:-(void) Senduserinfo: (Nsdictionary *) userInfo
Variable naming
- The first letter is lowercase and the first letter of each word is capitalized
- have sufficient explanatory
- Member variable does not need to add "_m" prefix
- Member variable Add "_" prefix
Constant naming
- Constant (predefined, local constant, etc.) using a camel-like hump method with lowercase k, for example: Kinvalidhandle, Kwriteperm
- The enumeration type is named with the first letter capitalized, followed by the first letter of each word, and the last "s"
- Enumeration variables use enum type to remove "s" as prefix, each word capitalized, and no underline is allowed in the middle
Example:
typedef enum UIControlEvents{UIControlEventTouchDown,UIControlEventTouchUpInside}UIControlEvents;
Picture naming
- Use English, capitalize the first letter, and then capitalize the first letter of each word
- Add a module name as a prefix to avoid collisions
- The picture should be grouped by module, just like the class file
Group naming
- Use English, capitalize the first letter, and then capitalize the first letter of each word
- Each grouping uses the name of the module
- Use the Open Source Library to be unified under the "library" sub-group
- Common components used uniformly placed under the "Common" group
- View Controller and Appdelegate unified under the "Controllers" sub-group
Writing specification Notes
- file contains the file header, to describe the file name, author, creation time, change record
- When multiple people collaborate on a project, each method of the public interface should add comments about functions, parameters, return values, and side effects
- When the judgment condition of the IF statement is complex, it is necessary to judge the content with the comment description
- Header files for interface classes (inherited from Baseclient) Each method should indicate the function of the method before
Method
- Leave a space between-or + and the return type, but do not leave the interval between the parameters in the parameter list, and each colon must have a descriptive word for the argument, such as: P-(void) dosomethingwithstring: (NSString *) string number: ( int) num
- If there are too many parameters, one row is recommended for each parameter. With multiple lines, use a colon before the parameter to align, such as:
-(void)doSomethingWith:(GTMFoo *)theFoo rect:(NSRect)theRect interval:(float)theInterval
Other specifications
- Add spaces before and after operators
- Avoid the same code snippet appearing in multiple places
- Statement nesting level must not exceed 3 layers
- Each implementation file is recommended to be within 500 lines, not more than 1000 rows, and should be considered after the code is refactored through an abstract class
- Delete or comment out useless code in time
- The network client inside the UITableViewCell must be commissioned.
- After clicking the button, you need to toggle the button picture, when the two pictures are not associated (for example, one picture has a check effect compared to another picture), should not be set to uicontrolselected
- Control layout uses relative coordinates
- Determine that unused code should be removed
iOS Code specification