Cainiao iPhone development-Hello World)

Source: Internet
Author: User

In the previous article, we briefly introduced several important concepts related to iPhone development. From this article, we will implement various applications of different scales.ProgramDevelopment. Let's start with the simplest "Hello World" application and learn how to create and develop an iPhone project.

 

Remind me again: our development is to install the iPhone SDKLeopardSystem.

 

Build Hello WorldApplications

 

Start xcode and select new project... from the File menu ..., Select the Application category under the iPhone title, select the view-based application template, click the choose button, type helloworld as the project name, and save it to the appropriate location. In this case, the new project is created and automatically opened in xcode.

 

 

 

Double-click the helloworldviewcontroller. XIB file to open it in interface builder. Window commonly used in interface builder includes the following four modules (from left to right): Main Window, View window, control library window, and attribute panel. If no View window is displayed, double-click the view icon in the main window.

 

Drag a label control from the control library and drag it to the View window. Double-click the label and type the text "Hello World !", You can customize settings in the attribute Panel, such as the background color, label font, and size of the window.

 

 

Save and return to xcode. Click the green icon buildand run on the toolbar. After the program is compiled, the iPhone simulator will be started to run our program.

 

 

At this point, you do not have to write anyCodeOur application is coming out, isn't it easy?

 

HelloworldProject Description

 

Now let's look back at the xcode project window. It is the main window for iPhone development. The toolbar at the top of the Project window provides many common commands. The window below the toolbar is divided into three main parts (or panes ).

 

The lower-left pane of the window is called the Group & files pane. All resources in the project are classified here. The upper-right pane is called the Detail View, which displays the details of the project selected in the Group & files pane. The lower-right pane is called Editor. If you select a file in Group & files or Detail View and xcode knows how to display such a file, the file content is displayed on the editor panel, editable files (suchSource codeYou can also edit it here.

 

Let's take a look at the group & files pane. The first item in the list should have the same name as the project (helloworld in this example). This item aggregates source code and other project-specific resources, currently, you only need to care about items under helloworld in the Group & files pane. Five subfolders are available: classes, other sources, resources, frameworks, and product.

 

    • Classes is the most commonly used folder. Most of the code you write is saved here (including all objective-C classes). You can create some subfolders in the classes folder to organize the code.
    • Other source contains source code files other than the objective-C class. The extension. PCH indicates precompliedheader (pre-compiled header file), and Main. M contains the main () method of the application.
    • Recsoueces contains non-code files in applications, such as, sounds, text files, and attribute lists required for running programs. The. XIB file can be directly connected to interfacebuilder for editing.
    • Frameworks is a special library that can contain code, images, sounds, and other resources. Any framework or Library added in this folder is linked to the application, the most common frameworks and libraries are linked in the project by default.
    • Products contains the application generated during compilation of this project .. When the app file is displayed in red, it indicates that the file cannot be found. After the file is correctly compiled and generated, it turns black.

 

At last, I am not planning to detail the various interfaces of interface builder. Interested readers can find relevant information and explore it carefully. However, interfacebuilder does not generate any code to be maintained, on the contrary, all the objective-C objects created by it will be serialized to the NIB file. (If you do not know what a NIB file is, click your search engine ), so that it can be directly loaded into the memory at runtime.

 

After completing the first iPhone application, we did not write any code. However, to develop more complex and powerful programs, it is inevitable to write objective-C code to process the logic between objects. Next, we will introduce in detail the syntax knowledge of objective-C, so that you can better control iPhone development.

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.