iphone development "One" started from HelloWorld

Source: Internet
Author: User

Reprint please indicate source, original website: http://blog.csdn.net/m_changgong/article/details/8013553 Zhang Yanquang

Start with the classic HelloWorld and enter the iphone development portal!

Keyword: HelloWorld IPhone IOS

1. Open Xcode and select "Create a New Xcode project"


2, the project in Xcode is divided into two categories, one is iOS, the other is Mac OS X, the former is Iphone/ipad development, the latter is for Mac PC development.

Select "Application" in the iOS category and select the "Single View Application" project template (each template feature below is explained below)

Xcodeproject Template Description:

Master-detail Application:
iphone device: The corresponding xcode4.0 navigation-based application, based on the navigation mode of the project template.
ipad Device: Splite view-based application of the corresponding xcode4.0, project template based on cut mode.
OpenGL Game: The corresponding xcode4.0 OpenGL ES application.
Single view application: The view-based application of the corresponding xcode4.0, based on the project template for the individual views.
Tabbed application: The corresponding xcode4.0 tab bar application, the project template based on the tab bar.
Utility application: The corresponding xcode4.0 Utility application, very little use, and at the moment is useless.
Empty application: Create a blank project with the window-based application of the corresponding xcode4.0.

3. Product Name: The name of the products (iphone app) produced by project


Company Identifier:com.zyg.ios, for application package name

Bundle Identifier:company identifier+product Name

The class name generated by class Prefix:project is added with the prefix that is filled in here

Device Family:project devices, iphone or ipad (the development of these two devices is different, the article will talk about later)


Use storyboards: Do not select the storyboard, the following article will be dedicated to the storyboard

Use Automatic Reference counting: Self-active reference count, selected after the memory release work does not need to handle, do not select, Learn iphone development must learn to control the memory release, real development can select the item.

Include unit Tests: whether the unit test is included, do not select, the following article specifically explains this.

4. Select the folder Iosdev, save the project

5. Expand Helloworldproject


HelloWorld: This folder is a logical folder and does not exist in the file system. It is a group in the Xcodeproject. The basic development is to create sub group or file under the group.
HelloWorldAppDelegate.h: proxy class header file
HELLOWORLDAPPDELEGATE.M: proxy class source file
HelloWorldViewController.h: View Controller class header file
HELLOWORLDVIEWCONTROLLER.M: View Controller class source file
Helloworldviewcontroller.xib: Includes user interface-related components
supporing files: The ability to store source files, is generally the storage of resource files.
Helloworld-info.plist: A list of properties that includes project information.
Infoplist.strings: Application internationalization, including multi-lingual translation.
MAIN.M: Including iphone application entry function Main, this file does not need us to do whatever changes.
HELLOWORLD-PREFIX.PCH: Includes a list of some header files. Xcode will precompile these header files, assuming that you need a large number of global variables in project, and that you can define macro variables as global variables in this file.
Frameworks: Introduced system framework, introduced by default
UIKit.framework:ios UI Component Class Library
Foundation.framework:ios Base Class Library
Coregraphics.framework:2d Drawing Class Library
Products: Includes product compiled after project Helloworld.app

6. Through the narration of the folder structure on the face we know that Helloworldviewcontroller.xib is the component that holds the user interface, click Open the file, locate the label component in the lower right corner of Xcode (you can enter a label in the search box to locate the component at high speed), drag the component to a blank view , the horizontal, vertical alignment of the Zillen line appears in the drag process, so that the label is horizontally, vertically centered with the label, and then double-click the lable and enter "Hello World".


7, hold Command (CMD) +b compile project, then Cmd+r, execute project, such as the following

Summarize:

1. Where is the entrance to the program? Start the process?

1) in the main function in MAIN.M, the function calls the Uiapplicationmain, and the last parameter is used to helloworldappdelegate, we have uiapplicationmain function started Helloworldappdelegat Class E.

2) The view controller Helloworldviewcontroller is initialized in the Didfinishlaunchingwithoptions method in HELLOWORLDAPPDELEGATE.M, and the initialization parameter is used to @ " Helloworldviewcontroller ", in fact, is helloworldviewcontroller.xib.

3) Helloworldviewcontroller.xib includes the user interface components, so after the view controller Helloworldviewcontroller initialization is complete, the UI component is displayed on the view, we hello World shows the emulator screen.

The program start process has the above concept can be, with the subsequent learning will gradually deepened, clearer.

2, the label component can be dragged onto the view display, no matter what other complex components theoretically can do so, thus showing.

3, Helloworldviewcontroller is called the View controller, then the control operation should be implemented in this class.

How do you interact with labels, control the display of labels, content, and so on? Take a look at the next article ...


Click to download this article source code

iphone development "One" started from HelloWorld

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.