Bloggers:Yi Feiyang
Original article:Http://www.yifeiyang.net/iphone-developer-advanced-2-iphone-applications-projects-constitute-a/
Reprinted text.
IPhone Development (2) --- iPhone applicationsProgram/Project Composition
When developing iPhone programs, what is first exposed is notSource codeBut the project file and directory. Let's take a look at its composition.
IPhone application directory structure
IPhone applications are placed in a secure structure called sandbox. The program can only access resources in its own sandbox.
IPhone applications and Mac OS applications are basically the same, but there are some differences in the program directory. You can use addressbook to construct other functions or constructor.
The directory structure of the iPhone application is as follows:
/Applications/ [Application1]/Application1.appDocuments/ Library/ TMP/ [Application2]/ Application2.app Documents/ Library/ TMP/ |
|
Composition of Project
Although the composition of a project varies by program, it is basically based on the MVC model. Therefore, the directory form is organized according to model, Controller, and view.
For example, the following directory structure:
- Classes
- Libraries (various middleware, libraries, etc)
- JSON
- Imagestore
- Other program modules
- Controllers (Class Related to View Controller)
- Uiapplicationdelegate
- Uiviewcontroller
- Views (custom view and Program Interface)
- Subclass of uitableviewcell
- Subclass of uiview
Project file structure
Next, let's take a look at what is in the program project:
Helloworld | -- Classes | -- Helloworldappdelegate. h | -- Helloworldappdelegate. m | -- Helloworldviewcontroller. h |'-- Helloworldviewcontroller. m | -- Helloworld. xcodeproj | -- Helloworldviewcontroller. XIB | -- Helloworld_prefix.pch | -- Info. plist | -- Mainwindow. XIB | -- Build |'-- Helloworld. Build '-- Main. m
|
|
-
. PCH
-
Pre-compiled header files are often encountered in Win32, which also contains common header files.
-
. Plist
-
Includes the features of the project, such as the project name, default loaded NIB file, and version.
-
. XIB
-
Program resource file. It is used to simplify the coding process and improve development efficiency.
-
Main. m
-
The iPhone program entry is similar to the main function in C/C ++.
The main function is as follows:
Int Main(Int Argc,Char*Argv[]) { NSAID utoreleasepool*Pool= [[NSAID utoreleasepoolAlloc] init]; Int Retval= Uiapplicationmain (argc, argv,Nil,Nil); [Pool release]; ReturnRetval; } |
|
The parameters argc and argv [] of the main function are the same as those in the C language and support command line input.
Next, create an NSAID utoreleasepool object to automatically manage the program memory.
|
NSAID utoreleasepool*Pool= NSAID utoreleasepool alloc] init]; |
The most important thing is the call of the following uiapplicationmain, which completes the system startup process and forms an event-driven.
|
Int Retval= Uiapplicationmain (argc, argv,Nil,Nil); |