When we entered the first day of the new company, see the old staff to write code, find something exhausting people, that scratching ah, under normal circumstances have to beat people's bright. Haha, not busy, first think of their own code! Think about the code you write how can the new people at a glance can understand, what to find, in a few seconds can be found? This will be in the early stage of the project to be careful, to ensure that the project is easy to read, easy to maintain and easy to expand and so on.
In my opinion, as a leader in project development, you can start with two aspects:
-
Schema of the project
-
Specification of code
I'm going to start with a new project today. Project Architecture (Code specification I will be listed in the next article in summary form), make the theory this I am not good, had to say the whole example. Considering that many people use "Sina Weibo" to practiced hand when they just learn OC, it is a good contrast to the iphone client of Sina Weibo, so it is better to see the problem. (In fact, the current market for all the basic applications are applicable, this article is a thought, regardless of the platform, regardless of language, as long as can understand, can be applied to the actual application development.) )
In order to create a code template that is easy to read, maintainable, and extensible for the project code, the builders of the project code are now required to follow these steps:
1. All new projects are best "single View application":
2, fill out the various projects, here note, the project name is best to use English:
3. Once the project is created, the first thing to do is to modify the target version of the minimum deployment system:
4, Next is the source file management, we look at the left navigation area:
-
All non-code source files are moved to "supporting files";
-
Select the. h and. M of Appdelegate and Viewcontroller, right-"show in finder", and then put Appdelegate and Viewcontroller. H and. m move to the trash, back to Xcode, delete the red files we just deleted (you can also right-->delete->movetotrash in Xcode, but sometimes it's dirty).
5. Import the project structure files that we have prepared (that is, the collection of folders and files of the project structure in this download view) to the same directory as the project name:
The result is this:
6, where the folder ' Qlclasses ' is the project of all the source code, ' qlresources ' is stored in all non-code resource files, the following two folders of the structure of the current structure of Sina Weibo detailed description. The overall frame chart is as follows (this is the focus):
-
Note that the image processing, in ' qlresources ' there is a ' qlimages ' folder, this folder is for special image files set up, you can not put all the pictures are here, this unscientific. It's best to put it in the assets.xcassets, so what are the pictures? In some projects, a large number of full-screen background images, such pictures we must not use [UIImage imagenamed:@ "ImageName"] way to load, Because this method will cache the image directly into memory, imagine, if a lot of pictures are plugged into memory what is the situation? That can only use [UIImage imagewithcontentsoffile:@ "ImagePath"] way, but we know that the image in Assets.xcassets will be packaged into a compressed file after the creation of the IPA, to reduce the memory footprint, this Where does ' ImagePath ' come from, so the problem is solved. Put these pictures under this folder, load the time directly with NSBundle to solve the problem of path, ok!
-
The project will certainly encounter multiple interfaces using the same data model problem, it is best to create two folders ' Qlcommonmodel ' and ' Qlcommonview ' two folders in the ' Qlmain ' folder for unified management.
-
Each folder in the structure you see in the left navigation of Xcode (except for supporting Files) must be mapped to a folder in the Finder so that we can quickly locate the location of the previously written tool class without opening the project. It is also convenient to view the structure of the current project in the Finder.
iOS new project file management specification