The development of iOS | code organization way

The development of iOS | code organization way
en

The significance of organizing code correctly:

Convenience is also convenient for others to quickly locate their own code, modify the code.

How to organize is correct:

Perhaps there are many ways to organize, each person’s habits and styles are different, but in any case, clear, clear is the real way of organization.

Share my personal organizational habits:

Or that sentence, everyone’s habits are different, there is no standard answer, but the final show must be simple and intuitive, pleasing. Above, a home page VC:

The development of iOS | code organization way
code module partition
The development of iOS | code organization way
connection

module partition with #pragma mark – large module, there will be a separate line;
large module in the small module division I generally use #pragma mark – small module

For the more complex VC, I was so partitioned:

1 lazy loading
lazy loading is basically doing some initialization operation, so I put it in the front. The project uses lazy loading a lot, in addition to the array, but should use lazy loading place: a scrollView sliding menu, several sub view controller (similar to the tabBarController system) such as create consumes more memory and time.
2 construction method
rewrite init method or custom init method, you can use custom init method, such as:

/ * * construction method, incoming goods ID * / - (instancetype) initWithGoodsID: (NSString * goodsID);

3 life cycle
in accordance with the order of the life cycle written in several ways:

The development of iOS | code organization way
written in sequence

4 static UI to build
static UI, refers to the fixed UI, such as navigation bar, return button, background color, etc., once they are created will not change.
5 data acquisition and analysis of
data acquisition and analysis is usually encapsulated in a specialized class, according to the incoming parameters directly to get the final data source.
6 dynamic UI display data content to build the so-called dynamic
, compared with static, the data obtained are different, the creation of UI is different. Only to get the data to build the page, it can only be carried out after data acquisition and analysis. For example, mixed graphics, the use of what controls, how to display, only after the acquisition of data to know.
7 page Jump
this is not much to say, write clearly:

The development of iOS | code organization way
page jump a touch more

8 other organizations classified according to the actual situation

There's a lot of stuff here

9 the last piece,
proxy method I used to proxy method written in the end, like a pile of tableView agent method, time to view the code of the press end or cmd+ key directly to the end.

The development of iOS | code organization way
system proxy method written in the final

Last

“Why are you so persistent with code?”
“because I’ve been hurt by someone else’s code, I don’t want to hurt anyone…”