iOS Programming specification

Source: Internet
Author: User

Coding specifications

I. Document Structure Management

1. Create A libraries folder where all third-party libraries are placed.

2. Create the Utilities folder, and put the self-encapsulated class into it.

3. CreateA C onstants.h header file, where all constants are defined. The Constants.h file is placed inside the main filegroup.

4. Each function block is put into a group to establish the actual folder management in the directory.

5. The program resource file is placed in the supporting Files folder. such as . plist, database data, etc.

6. Create an image, music, video and other related folders under the supporting Files folder. Images, audio, video, and other resources are placed in them . Picture resources to the program logical framework to establish the corresponding Entity folder management, if more than one function block shared, set up the common folder, put into it.

Second, the Code specification: in order not to affect reading, the number of lines in a class should not exceed 300 lines; One method try not to exceed 30 rows. There are more than one way to break down when refactoring.1. at the beginning of each. h file, describe the functional logic of the class in short text.

2. when introducing other classes, to be introduced as instance variables in . h. Otherwise, it is introduced in . M.

[Email protected] andan empty line between the @implementation and the #import . @synthesize followed by @implementation writing.

4.a: Declaring instance variables are declared as attributes.

B: The instance variables and methods to be accessed by other classes are declared in the. h file, otherwise declared in the . M file.

 C: instance variables and methods are put together with function blocks to implement a function that is put together consecutively, and the other function's empty line begins to declare.

 D: The instance variable starts immediately after the @interface , and the method begins with an empty line after the instance variable.

 E: each function block can be simply explained, the single instance variable method can not be described, the key or special variables or methods are described separately. Note is released on a row of the variable declaration.

5. The first function module in the class is separated by #pragma mark- two lines above, and an empty line.

6.NSLog is removed after the test is complete.

7. add a suffix when declaring an instance variable for a system's common class:

Uiviewcontroller:vc

Uiimage:img Uiimageview:imgview Uiview:view Uilabel:lbl

UIBUTTON:BTN Uinavigationbar:nbar Uitoolbar:tbar Uisearchbar:sbar

Uitextfield:textfield Uitextview:textview

Nsarray:array Nsmutablearray:marray

Nsdictionary:dict nsmutabledictionary:mdict

Nsstring:str Nsmutablestring:mstr

Nsset:set Nsmutableset:mset

8. The variables, method names in the program as far as possible literal meaning function, for the need to use comments to explain the part of the code, comments are expressed in the following format:

/**

* Method or Variable description

* @param parameter 1 description (for method)

* @param parameter 2 description (for method)

* @return The return value is described if the method has a return value

*/

Three, Xcode configuration

1. All unified with arc.

2. Use git to manage your code.

3. Add a section of the NSLog code that removes the release from the project. pch File:

#ifndef __optimize__

#define NSLOG (...) NSLog (__va_args__)

#else

#define NSLOG (...) {}

#endif

iOS Programming specification

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.