IOS encoding specification (documentation)

Source: Internet
Author: User

File naming specification:

1. The project uniformly uses the class prefix zy.

2. Category naming + The following unified use Zyextension, example: Nsdictionary+zyextension.h, the common classification is defined internally and writes good documentation comments. If the functional classification of internal methods are more likely to consider by function name.

3. Model files can be named by Server Interface name or field name, and view, ViewModel, and controller files can be named by function.

4. transduction name:home_menu_chat,-> Module _ function _ specific name, transduction name is very important, this can communicate with the fine arts, let them directly named good again to us, can greatly improve the development efficiency, but do not use Chinese.

Code specification:

1. The classification method begins with Zy_ and can be differentiated from system or third-party framework methods.

2. The string or base data type used globally is defined as constants rather than macros. And only use the static modifiers available inside a file, and do not expose the. h file.

3. The macro definition begins with Zy_ and is uniformly capitalized, delimited by _.

4. The intra-class methods are divided by function and uniformly using #pragma mark < #xxxx #>.

5. When the method parameter is more, the line should be changed to align its parameters and improve the readability.

6. Method attribute comments Use document comments as much as possible to download a plugin vvdocument.

7. Define member variables must be underlined in accordance with the Apple specification.

8. Controls and properties are created with lazy loading whenever possible, so that they are guaranteed to be created again. Note that using lazy loading is not directly accessed with the underscore member variable name and should be accessed using the Get method.

9. Method callbacks use block callbacks as much as possible to improve code aggregation, but be aware of circular reference issues, and it is recommended that you use weak references inside the block.

10. The Declaration string property must use copy, the proxy uses weak, but use the proxy as little as possible, the block callback is more convenient.

11. Note the method and properties, and the name of the camel for the member variable.

12. destructor-(void) Dealloc best placed on the top of the class, you can see this method at the first glance, you can easily see whether to clear the resources.

13. A single method code should try not to exceed 100 lines, a single file code not more than 800 lines, such as more than can be considered for refactoring optimization.

14. The same logical method, or a number of methods used can give priority to the classification of the extraction, and then consider pumping a tool method class.

15. Define the control or controller must be followed by the control name, such as a imageview->uiimageview *iconview, do not directly use Uiimageview *icon.

16. Judge Yes/no/nil to use this notation

17. Load picture suggest custom UIImage A classification method, for example: [UIImage zy_imagenamed:@ ""]. Can be intercepted in the change method, skin may be used.

18. All network requests begin with request. Example: Returns the result with block and corresponds to a data model, and error. A request error when error has a value. Recommended third-party framework: Yymodel-A dictionary-to-model framework, performance is now better than the mainstream framework, and easy to use. Yycategories provides some common classification methods, which can greatly accelerate the development efficiency. Yywebimage-Load network picture frame, can have animation effect, better than sdwebimage. Mjrefresh, drop-down refresh control afnetworking, Web request Pop, Facebook animated frame, Svprogresshud, a single-class, globally shared, without the need to create consumption performance repeatedly Maso Nry, auto-layout Framework Realm---The most recent database framework for fire, it is said that performance seconds kill CoreData and SQLite, and the learning cost is very low. Reactivecocoa-A functional responsive programming framework.

IOS encoding specification (documentation)

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.