IPhone applicationsProject composition case implementation is the content to be introduced in this article, mainly to understand and learn how a project is made up. First, let's look at the details. DevelopmentIPhone applicationsFirst, it is not the source code, but the project file and directory. Let's take a look at its composition.
IPhone application directory structure
The iPhone application is put into 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 and Libraries)
- JSON
- ImageStore
- Other program modules
- Controllers and View Controller classes)
- UIApplicationDelegate
- UIViewController
- Views: Customized Views and program interfaces)
- 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 application entry is similar to the main function in C/C ++.
The main function is as follows:
- int main(int argc, char *argv[]) {
- NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
- int retVal = UIApplicationMain(argc, argv, nil, nil);
- [pool release];
- return retVal;
- }
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.
- NSAutoreleasePool * pool = NSAutoreleasePool 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);
Summary:IPhone applicationsThe project composition case has been introduced. I hope this article will help you! For more information, see the following articles:
IPhone Development 2) iPhone application startup process
IPhone Development (advanced 3) custom UIViewController case implementation
IPhone Development (Advanced 4) UIButton Case Study