IPhone development (1) Case Study of iPhone application project composition

Source: Internet
Author: User

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:

 
 
  1. /Applications/ [Application1]/Application1.appDocuments/  
  2. Library/  
  3. tmp/   
  4. [Application2]/  
  5. Application2.app  
  6. Documents/  
  7. Library/  
  8. 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:

 
 
  1. Classes
  2. Libraries various middleware and Libraries)
  3. JSON
  4. ImageStore
  5. Other program modules
  6. Controllers and View Controller classes)
  7. UIApplicationDelegate
  8. UIViewController
  9. Views: Customized Views and program interfaces)
  10. Subclass of UITableViewCell
  11. Subclass of UIView

Project file structure

Next, let's take a look at what is in the program project:

 
 
  1. HelloWorld  
  2. |-- Classes  
  3. |   |-- HelloWorldAppDelegate.h  
  4. |   |-- HelloWorldAppDelegate.m  
  5. |   |-- HelloWorldViewController.h  
  6. |   `-- HelloWorldViewController.m  
  7. |-- HelloWorld.xcodeproj  
  8. |-- HelloWorldViewController.xib  
  9. |-- HelloWorld_Prefix.pch  
  10. |-- Info.plist  
  11. |-- MainWindow.xib|-- build  
  12. |   `-- 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:

 
 
  1. int main(int argc, char *argv[]) {      
  2. NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];      
  3. int retVal = UIApplicationMain(argc, argv, nil, nil);     
  4.  [pool release];     
  5.   return retVal;  
  6. }   

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

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

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.