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

Source: Internet
Author: User

 

  • 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);
  • 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.