IPhone Development Series (I)-iPhone OS Overview

Source: Internet
Author: User

I have translated and summarized it based on the technical documents of the iPhone Dev center.

Reprinted please indicate the source: http://blog.csdn.net/zhyzh2046/

The iPhone OS consists of two parts: the operating system and the technology that can run native programs on the iPhone and iPod Touch devices. Because the iPhone is developed for mobile terminals, the user requirements to be addressed are somewhat different from those of Mac OS x, although the iPhone shares some underlying technologies with Mac OS X. If you are a Mac developer, you can find many familiar technologies on the iPhone OS, and also notice the uniqueness of the iPhone OS, such as multi-touch interface) and accelerometer ). Although I have not yet set up an iPhone development environment, I need to learn many new technologies based on my previous understanding of the iPhone. For example, the multi-Contact Technology and sensor control technology are used in software design. For iPhone and iPod Touch, it looks pretty cool.

 

Before the SDK is released, third-party programs cannot run on the iPhone (some hackers can run third-party programs ). With the release of the SDK, iPhone enthusiasts can develop applications running on the iPhone. The iPhone SDK contains the required materials and tools that can be used to develop, test, run, debug, and tune programs for iPhone OS. Xcodeide has been updated to support iPhone OS development. In addition to the basic code editing, compilation, and debugging environment, xcode also provides the launching point function when debugging your program on an iPhone or iPod Touch device. I don't know what this is like. It is estimated that the breakpoint is set on the actual device and the running log information is displayed. At the same time, xcode can run programs in the iPhone simulator. The simulator is a platform that simulates the basic iPhone OS environment on a Macintosh computer. I like it very much. Due to limited conditions, I can only view the effects of my programs on the Virtual Machine and run the programs on the real machine when I have the strength. The simulator is quite convenient for learning the programming process and language of the iPhone.

This article outlines the basic features of the iPhone OS and helps you familiarize yourself with this platform. In fact, this article is basically translated from the iPhone Dev center, but not completely. I deleted some redundant information and added my own opinions. please correct me if you have any flaws.

Technical hierarchy of iPhone OS

In iPhone OS, the underlying system architecture and many other technologies are very similar to those in Mac OS X. Because the iPhone OS kernel is based on the Mach kernel change in Mac OS X 10.5. In fact, the kernel of Mac OS X 10.5 Mach is cropped accordingly, along with the support of iPhone-specific technologies. A service layer is built on the kernel. You can use these services to develop applications on the platform. Figure 1 shows an overview of these layers.

Figure1 iPhone OS technical hierarchy

This layer provides multiple options for development. The following two layers interact directly with the hardware. For example, the core OS and core services layers contain basic interfaces of the iPhone OS, including file access, underlying data types, bonjour services, and network sockets. Most of these interfaces are based on C language, including core Foundation, cfnetwork, SQLite, POSIX thread access, and Unix sockets. I think the iPhone kernel should be written in C, and the Mach kernel is a UNIX kernel, so the two layers are used for program development, it is equivalent to using Linux APIs for program development. On these two layers, you can use your code to directly operate the hardware. Of course, you need to be familiar with the underlying development.

The above two layers have more advanced technologies that use a mix of C-based and objective-C-based interfaces. For example, the media layer contains basic technologies that support 2D and 3D plotting, audio, and video. This layer includes C-based technologies: OpenGL ES, quartz, and core audio. It also contains core animation, which is an advanced animation engine based on objective-C. Objective-C language is an object-oriented extension of C, which can be seen as the same as the QT library in Linux, you can use objective-C-based interfaces like using QT classes and interfaces. These interfaces are encapsulated in objective-C language, which can shorten the development time, but the premise is to be familiar with objective-C language.

On the top layer-the cocoa touch layer, most of the technologies use objective-C. Many frameworks in this layer provide basic underlying structures for your program. For example, the foundation framework provides object-oriented support for collection, file management, and network operations. The uikit framework provides a visual underlying architecture for your program, including windows, views, controls, and controllers that manage these objects. Other frameworks in this layer allow you to access user contact and image information, as well as accelerators and other hardware features on the device. After reading several iPhone programs, I found that the most used is the uikit framework, which provides the controls required by a simple graphic interface program, therefore, you can be a programmer unfamiliar with Linux or Unix development. You only need to learn how to use controls in the uikit framework, and you can create an iPhone program.

The starting point of the new project should be the cocoa touch layer, especially the uikit framework. When selecting additional technologies, it is recommended that you start from the high-level framework. When necessary, you should turn to the lower-level framework. If you want to use the least effort in your program to support standard system behavior, a higher level of framework will make the process simple. This is the only time to use a lower-layer framework to implement custom behaviors that are not provided at the higher level.

For more detailed technical overview of iPhone OS, seeIPhone OS programming guide.

I personally think that Beginners should start from the top layer, especially those who have no experience in MAC development. The upper-layer framework will save you time for development, and the upper-layer framework is very powerful and can basically meet all the technologies required by a simple program.

Write code for iPhone OS

The iPhone SDK can create graphical interfaces running on the iPhone OS. When running a self-developed program, the program will reside on the main screen, which is the same as other system programs, such as photos, weather, and clock. When running a program, apart from the kernel and some underlying background programs, it is the only program running on the system. When the program runs, the entire screen is occupied, and only your programs can be seen by the user. When you click the Home button, the home page of the system is displayed when the program exits. An exclusive system provides full access to underlying system resources. You can use built-in hardware such as accelerators, cameras, and graphics hardware to run your code only.

Because the interaction between users and iPhone and iPod Touch devices is essentially different from that between Mac OS X, the way users design applications is also different. The main difference is that the user input method is very different. on Mac OS X, the keyboard and mouse are used to capture the user input, and the system responds. On the iPhone, the OS captures user input through the touch screen and processes user input with multiple contacts. In iPhone applications, there is no concept of a separate file window when displaying content, and all data of the program is displayed in a Single Window. This produces new views and controls that display your application data in an organized style. In addition, many views and controls are different from those in Mac OS X. Most of the changes are transparent, but there are some ways that you need to rethink the organization and presentation of data.

For traditional desktop applications, the iPhone OS event processing model is also an important milestone. IPhone OS introduces the concept of touch events, rather than relying on traditional mouse and keyboard events. A touch event occurs at any time and can be combined with one or more touch events. Touch events can be used for simple interaction with content, such as selecting or dragging items, or for detecting complex posture and interaction actions, such as re-clicking or opening or disabling scaling actions. (For example, used in a photos program to zoom in or zoom in ). In fact, this is a major innovation of the iPhone. In its own programming and architecture, we should try our best to use this advantage to give users a better user experience.

When development starts, the foundation and uikit frameworks will be used initially. These two frameworks provide key services for all iPhone applications. When refining your applications, you should study other frameworks of the system to see what services they provide. Each Framework document contains links to relevant concepts and materials, which will help you learn more about using this framework.

Where to start

Using the built-in Project template provided by xcode, you can easily create simple applications. However, creating practical and beautiful applications requires you to spend some time reading existing documents. At least you should spend some time reading several other guiding articles in the iPhone Dev center, which study the tools and application development processes. For beginners, the task is to learn these articles and run a helloword program. This is enough.

If you are not familiar with the development of iPhone OS and Max OS x, you must first understand the basic design patterns and iPhone OS conventions. To develop an iPhone program, try to use the framework provided by the system as much as possible so that your program can run smoothly in the iPhone. If you go deep into the basic functions of the framework, you will find it much more difficult to create your own applications in practice than simply learning the basic design patterns.CocoaBasic GuideContains the basic knowledge that every iPhone developer needs to know. This document introduces the basic knowledge, programming habits, design patterns used by uikit, and many other system frameworks of objective-C programming language.

Once you understand the basic habits of creating an iPhone application, you canIPhone OSProgramming Guide. This Guide contains examples of how to write the key concepts and task-oriented data for iPhone applications, how to display user interfaces, handle events, and utilize the features of the main iPhone OS. It also describes all the development processes and describes how to use xcode to compile and run applications.

DivisionIPhone OSProgramming GuideIn addition, you 'd better read the existing instance code. The iPhone OS provides many full-featured examples to show how to use existing technologies to create real applications. You can use these examples as the starting point for your own application, or use them to learn more about how to use specific features. There are a lot of sample code in the iPhone Dev center, which is simple, but it helps you learn the iPhone program framework and objective-C language.

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.