iOS Basics-Programming specifications

Source: Internet
Author: User

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

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.