IPhone Development (2) --- composition of iPhone applications/Projects

Source: Internet
Author: User

When developing an iPhone program, the first thing that comes into use is not the source code, but the project files and directories. 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.app
Documents/
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 utoreleasepool 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.

1 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.

1 int retVal = UIApplicationMain (argc, argv, nil, nil );

Next we will explain how to start the iPhone application.

Author: Yi Feiyang

Related Article

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.