To develop good programming habits is the first prerequisite for starting a new language.
(i) Document structure specification
1. Create a Libs folder to store third-party libraries
2. Create Tools folder to store your own packaged class library
3. Create the Viewcontrollers folder and store all the Viewcontrol
4. Create a request folder to store network requests
5. Create a cell folder and store the list item
6. under the supporting Files folder, create Images,Music , and Video and Other related file folders, respectively, storage of pictures, audio, video and other resources.
7. Set up Rootviewcontroller home page, put in the bottom directory
8. Create the Constant.h file, put it in the underlying directory, and store the constants
Examples are as follows:
(ii) Naming conventions
1. Constant names are all uppercase and can be separated by underscores, such as: my_lottery_id
2. The first letter of the variable is lowercase and the first letter of the following word is capitalized, such as Mylotteryid
3. Class name capitalized, such as @interface Mylotteryid:nsobject
4. Name with the type, such as XXXTV,XXXVIEW,XXXSTR, etc.
Common types are abbreviated as follows:
UIVIEWCONTROLLER:VC uiimage:img Uiimageview:iv
Uiview:view Uilabel:lbl uibutton:btn
Uinavigationbar:nbar Uitoolbar:tbar Uisearchbar:sbar
UITEXTFIELD:TF UITEXTVIEW:TV Nsarray:array
Nsmutablearray:marray nsdictionary:dict nsmutabledictionary:mdict
nsstring:str nsmutablestring:mstr Nsset:set Nsmutableset:mset
5. The static variable is preceded by the S flag, such as Slotteryid
More naming conventions available in Apple's official documentation
(c) Coding habits
1. A brief description of the role of the file before each file
2. class function module with #pragma mark-make notes, easy to find and code management
3.NSLog Unified Delete after test
4. The variable method name in the program, as far as possible with the naming function, can not be marked with the explanatory notes
5. Loading preprocessing and log auto-removal settings in PCH file
6. Class code line number as far as possible not more than 300 lines, a function not more than 100 lines, more than the consideration of refactoring
7. Create Constant.h File Store constants