The iOS ecosystem
The iOS ecosystem is not just about products, but more importantly Iphone/ipad/ipod/mac +icloud+app the entire system, including Siri (not supported on some devices), FaceTime, Safari, Game Center, maps, Passbook, telephone, mail. Apple all mobile devices use their own OS, and can not replace the battery, can not plug in the memory card, the data cable connected to the computer can only through the Home software itunes file transfer, only the use of Apple-approved software, and software can only be downloaded from the App Store, which constitutes a closed ecosystem.
Look at a set of data:
Users spend about $4.5 billion in App Store in 2012
Users spend more than $10 billion in the App store in 2013
2014 Q1 Domestic iOS game market has exceeded 1.2 billion of quarterly revenue
2014 Q1: Apple App Store app downloads are 45% lower than Google Play, but revenue is higher than the latter 85%,app store China revenue rose 70% from the previous quarter.
iOS architecture
iOS from bottom to top can be divided into four layers: Core os,core Services,media,cocoa Touch.
Core OS
Darwin, rewritten with FreeBSD and Mach, is an open source, POSIX-compliant UNIX core. This layer provides basic functionality for the entire iphone OS, such as: Hardware drivers, memory management, program management, thread Management (POSIX), File system, network (BSD sockets), and standard input and output, all of which are provided through the C language API. Also, it is worth noting that this layer has the most Unix color, and if you need to port the programs developed on UNIX to the iphone, you will probably use the core OS API. The driver of the core OS layer also provides the interface between the hardware and the system framework. However, due to security considerations, only limited system framework classes can access the kernel and drivers. The iphone OS provides many interface sets to access the low-level features of the operating system, and the iphone app accesses these features through the Libsystem library, which are as follows:
- Threads (POSIX threads);
- Network (BSD sockets);
- File system access;
- Standard I/O;
- Bonjour and DNS services;
- Site information (locale information);
- memory allocation;
- Mathematical calculations.
The header files for many core OS technologies are located in directory <iphonesdk>/usr/include/,iphonesdk, which is the SDK installation directory.
Core Services
Provides richer functionality on core OS, which includes foundation.framework and core Foundation.framework, which is called Foundation because it provides a range of processing strings, permutations, combinations, calendars , the basic functions of time and so on. The foundation is the Api,core fundation belonging to Objective-c, which belongs to the C API. In addition, Core Servieces offers other features such as Security, Core location, SQLite, and Address Book. Where security is used to handle authentication, password management, security management, Core location is used to handle GPS positioning, Sqllite is a lightweight database, and addressbook is used to process phone book data. Here is a detailed description:
(1) telephone frame (addressbook.framework)
Provides a phone-based programming interface that is saved in a mobile device. Developers can use the framework to access and modify records stored in the user's contact database.
For example, a chat program can use the framework to get a list of possible contacts, start a chat process, and display these contact information on the view.
(2) Core Infrastructure Framework (Corefoundation.framework)
is a C language-based interface set that provides basic data management and service capabilities for iphone applications. The framework supports the following features:
- Collection data Types (Arrays, sets, etc.);
- Bundles;
- string management;
- Date and time management;
- Raw data block management;
- Preference management;
- URL and stream operation;
- Thread and run loop (run Loops);
- Port and socket communication.
The core infrastructure is closely related to the underlying framework, which provides the Objective-c interface for the same basic functionality. If developers mix the foundation Objects and Core Foundation types, they can take full advantage of the existence of the "toll-free bridging" in two frameworks.
Toll-Free bridging means that developers can use either of the core foundations and underlying types of the two frameworks, such as collection and string types. The description of the class and data type in each frame indicates whether the object supports toll-free bridged. If so, which object it is bridged with (toll-free bridged).
(3) Cfnetwork frame (cfnetwork.framework)
is a set of high-performance C-language interfaces that provide object-oriented abstraction of network protocols. Developers can use the Cfnetwork framework to operate the protocol stack, and can access low-level structures such as BSD sockets. At the same time, developers can simplify the communication with FTP and HTTP servers, or resolve tasks such as DNS. The tasks implemented using the Cfnetwork framework are as follows:
- BSD Sockets;
- Use SSL or TLS to create an encrypted connection;
- Parsing DNS Hosts;
- Parsing HTTP protocol, authentication HTTP and HTTPS server;
- Working on the FTP server;
- Publish, parse, and browse Bonjour services.
(4) Central location Framework (core site framework)
It mainly obtains the current latitude and longitude of the mobile device, and the core position frame uses the nearby GPS, cellular base station or Wi-Fi signal information to measure the user's current position. The iphone Map app uses this feature to display the user's current location on the map. Developers can integrate this technology into their own applications, providing users with some location information services.
For example, you can provide a service that looks for nearby restaurants, stores, or devices, based on the user's current location.
(5) Security framework
In addition to the built-in security features, the IPhone OS also provides an external security framework to ensure the security of application data. The framework provides interfaces for managing certificates, public/private key pairs, and trust policies. It supports the generation of cryptographic security pseudo-random numbers, as well as the certificates and keys saved in the keychain. For user-sensitive data, it is a secure knowledge base (Secure Repository). The Commoncrypto interface also supports symmetric encryption, HMAC, and data summarization. There is no OpenSSL library in the iphone OS, but the functionality provided by the Data digest is essentially consistent with the functionality provided by the OpenSSL library.
(6) SQLite
Developers can create local database files and manage the tables and records in these files. Database SQLite is designed for general purpose, but can still be optimized for fast access to database records. The header file that accesses the database SQLite is located in <iphonesdk>/usr/include/sqlite3.h, where <iPhoneSDK> is the target path for the SDK installation.
(7) Support XML
The underlying framework provides the Nsxmlparser class for parsing XML document elements. The LibXML2 library provides the ability to manipulate XML content, an open source library that can quickly parse and edit XML data, and transform XML content into HTML. The header file that accesses the LibXML2 library is located in the directory <iphonesdk>/usr/include/libxml2/, where <iPhoneSDK> is the target directory for the SDK installation.
Media layer
Provides multimedia features such as pictures, music, videos and more. The image is divided into 2D images and 3D images, the former is supported by quartz2d, while the latter is opengles. The module that corresponds to music is core audio and OpenAL, Media player implements the playback of the movie, and finally provides the core Animation to support the powerful animations. The details are as follows:
(1) Image technology (graphics Technologies)
High-quality images are an important part of all iphone applications. At any time, developers can use the views and features already in the Uikit framework and pre-defined images to develop iphone apps. However, when the views and functions in the Uikit framework do not meet the requirements, developers can apply the techniques and methods described below to make the view.
①quartz Core Image frame (coregraphics.framework)
The quartz 2D drawing Api,quartz is as advanced as the vector drawing engine used in Mac OS. Quartz supports path-based (path-based) drawing, anti-aliasing (anti-aliased) overloading, gradients (gradients), images (Images), Color (Colors), Coordinate space transformations (coordinate-space Transformations), PDF document creation, display, and parsing. Although the API is based on the C language, it uses object-based abstract representation of the underlying drawing objects, making the image content easy to save and reuse.
② Core animations (core Animation)
The Quartz core framework (quartzcore.framework) contains the Coreanimation interface, and core animation is an advanced animation and compositing technique that uses an optimized overloaded path (Rendering Path) for complex animations and virtual effects. It uses a high-level OBJECTIVE-C interface to configure animations and effects, and then overloads the hardware for better performance. Core animation integrates into many parts of the iphone OS, including Uikit classes such as UIView, which provides animations for many standard system behaviors. Developers can also use the Objective-c interface in this framework to create customized animations.
③opengl ES
The OpenGL ES Framework (Opengles.framework) complies with the OpenGL ES v1.1 specification, which provides a tool for painting 3D content. The OpenGL ES Framework is a C-based framework that is closely related to hardware devices and provides high frame rates for full-screen gaming applications (hi-frame rates). Developers always use the Eagl interface of the OpenGL framework, the EAGL interface is part of the OpenGL ES Framework, which provides the application's OpenGL ES drawing code and the interface of the local window object.
(2) Audio Technology (Technologies)
IPhone OS Audio technology provides a rich audio experience for users. It includes audio playback, high-quality recording and triggering of the device's vibration capabilities. IPhone OS's audio technology supports the following audio formats: AAC, Apple Lossless (ALAC), A-law, IMA/ADPCM (IMA4), Linear PCM, Μ-law, Core audio, and more.
① Core Audio Family
The core audio family of frameworks provides local support for audio, as shown in table 16-1. Core Audio is a C language-based interface and supports stereo (Stereo Audio). Develop a core audio framework that uses iphone OS to generate, record, mix and play audio in iphone apps. Developers can also access the vibration capabilities of their mobile devices through core audio. Core Audio frame:
FRAME (framework) |
Services (service) |
Coreaudio.framework |
Define audio data types for Core audio |
Audiounit.framework |
Provides audio and streaming files Playback and recording, and manage sound Frequency files and playback cue sounds |
Audiotoolbox.framework |
Provides the use of built-in audio unit services, Audio Processing Module |
②openal
The IPhone OS also supports the Open Audio Library (OpenAL). OpenAL is a cross-platform standard that delivers location audio (positional). Developers can apply openal to achieve high-performance, high-quality audio in games or other applications that require location audio output. Since OpenAL is a cross-platform standard, code modules with OpenAL can be migrated smoothly to other platforms.
(3) video technology (video Technologies)
The IPhone OS supports full-screen video playback through the media playback framework (mediaplayer.framework). The video file formats supported by the media playback framework include. mov,. mp4,.m4v and. 3gp, and apply the following compression criteria:
①h.264 Baseline Profile Level 3.0 video with a resolution of 640x480 pixels in the case of the f/s. Note: b frames is not supported;
②MPEG4 the video part of the specification;
③ numerous audio formats included in the list of audio technologies, such as AAC, Apple Lossless (ALAC), A-law, IMA/ADPCM (IMA4), linear PCM, Μ-law, Core audio, and more.
Cocoa Touch
Is the Objective-c API, the most central part of which is uikit.framework, the application interface of the various components, all provided by it to provide rendering, in addition to it is also responsible for processing on-screen multi-touch events, text output, pictures, Web page display, camera or file access , as well as the acceleration sensing part. The details are as follows:
(1) UIKit frame (uikit.framework)
Contains the OBJECTIVE-C program interface, which provides a key architecture for implementing graphics, event-driven iphone applications. Each application in the IPhone OS uses this framework to achieve the following core functions:
- Application management;
- Support graphics and Windows;
- Support Touch event processing;
- User interface management;
- Provides objects used to characterize standard system views and controls;
- Support text and Web content;
- Integration with other applications via URL scheme.
To establish an application for basic code, Uikit also supports some special device-related features, as follows:
- Accelerometer data;
- Built-in camera;
- User Picture Library;
- Device name and mode information.
(2) Infrastructure Framework (Foundations framework)
The following features are supported:
- Collection data types (including arrays, sets);
- Bundles;
- string management;
- Date and time management;
- Raw data block management;
- Preference management;
- Threads and loops;
- URL and stream processing;
- Bonjour;
- Communication port management;
- Internationalization.
(3) Phonebook UI Framework (Address Book UI Framework)
is a OBJECTIVE-C standard program interface that is used primarily to create new contacts, edit and select contacts that exist in the phone book. It simplifies the display of contact information in iphone apps and ensures that all applications use the same program interface to ensure consistency across different platforms.
Summarize:
use the high-level framework whenever possible , when we want to develop the iphone program, the first thing is to start from the top, priority to use the Objective-c encapsulated library.
That is, through Uikit.framework collocation foundation.framework to develop, and when facing some more complex functions, such as multimedia processing or drawing, then go down to find the relevant framwork to complete.
MVC layout
In fact, in PHP, including Java (struts+hibernate/mybatis+spring) are involved, a very common pattern. Memories to be organized under:
Objective:
The human-computer interaction is separated from the core function, the model is not visible to the user, the user only needs to observe view views, the user interacts with the model through the security method provided by controller controllers.
MVC (Model-view-controller) divides an interactive application into 3 components
Model: Contains core functions and data (core business logic)
Views: Displaying information to users
Controller: Handling User input
Change-propagation mechanism ensures consistency between the model and the user interface
A model can correspond to multiple views, and if the user changes the data in the model through a view's controller, other views that depend on that data should also reflect this change. Once the model's data has changed, the model needs to notify all relevant views to make corresponding changes to maintain the consistency of the data.
Model
The kernel functions and data are encapsulated, the model is invisible to the user (M and v Independent), the model is independent of the specific output representation or Input method (M and C Independent), the user can only operate the model through the controller (c is the bridge between M and V)
views View
Display information to the user, different views use different methods to present the information,
Each view component has an update function, which is activated by the model change notification.
is activated (when the model has changed), the view is re-aligned with the model.
During the initialization phase, the view registers the request change notification (table) with the model.
Getting data from a model
Implemented by State query functions.
Example: Timed Refresh
Controller controllers
Each view has a related controller component (one by one corresponds), the controller component accepts the event and translates it into input, how the event is sent to the controller is determined by the user interface platform, and the event is translated into a request for the model or view, if the controller's behavior depends on the state of the model, Then the controller also needs to register the change notification with the model.
For example: The user clicks the button, the button's event response function will take the appropriate action to handle the user request, the user only through the controller and the system interaction
Note: Multiple MVC can work together
IOS overall architecture and MVC layout