IOS8 understand how application extensions work

Source: Internet
Author: User
Tags terminates

understand how application extensions work

Source: http://www.cnblogs.com/chensheng12330/p/3947435.html

On this page

An application extension is not an application that implements a specific narrower task, insisting that the policy is defined as a specific extension point.

application extension life cycle

Because application extensions are not an application, Its life cycle and environment are different. In most cases, an extension is emitted when the user chooses the UI or active view controller from an application. An application that the user chooses to use is called an application extension   host application  

For example, suppose a user chooses some text in an OS X host application, activates the Share button, selects an app extension from the share list, and helps them to bring the text to social sharing sites. The host application responds to the user's selection by extending the request to include the selected text. In this case, the first step of the generalized version diagram is 2-1 .

Figure 2-1 Basic Lifecycle extensions for an application

at step 2   

in step 3 of the Figure 2-1 , user-executed or canceled tasks apply extensions and denials. In response to this action, the request to extend the completion of the host application executes the user's task immediately, or, if necessary, initiates a background process to execute it. The host application destroys the extended view and the user returns them before the host application context. When the extended task finishes, whether immediately or later, the result may be returned to the host application.

The system terminates the extension shortly after the application extension executes its task (or begins a background session execution), as shown in step 4.

how application extension communication

when an application is being run, it communicates primarily with the host application. figure 2-2 shows a simplified view of the relationship between the running extension and the launch of its host application, which contains the application.

Figure 2-2 the running application extension communication is only directly related to the host application

There is no direct communication between the application extensions and the applications it contains, and typically, the containing application is not even run-time with the extension running. Application extensions include applications and host applications that simply cannot communicate.

When an application extension needs to contain an application with it, it indirectly passes through the Span class= "Apple-converted-space" >&NBSP; extension context &NBSP; built the host application. For example, an extension might require that its containing application open a URL. In this example, the extension uses the API, not the direct message that contains the application. In addition, an extension that contains data that an application can access and a shared container that is privately defined. The extensions of these types of indirect communication and the applications it contains are shown &NBSP; < Span id= "outfox_jtr_trans_node-49" class= "Outfox_jtr_trans_node" "Diagram 2-3 

Figure 2-3 an application extension that is running contains an application that can communicate indirectly

Please note

Behind the scenes, the system uses interprocess communication to ensure that host applications and application extensions can work together to make a cohesive experience. In your code, you never think about this potential communication mechanism because you are using more advanced APIs to provide extension points and systems.

Some APIs for application extensions are not available

Because of its role in the centralized system, application extensions are not eligible to participate in certain activities. Application Extensions cannot:

  • access a sharedApplication  Object , and therefore cannot use any method of the object

  • header Files NS_EXTENSION_UNAVAILABLE  that use any API flags Macro

  • Access the camera or microphone on your iOS device

  • Perform background tasks (although application extensions can initiate uploads or downloads using nsurlsession  object)

  • Receive data using AirDrop

(Application extensions use AirDrop to send data applications the same way: using UIActivityViewController  Class)

IOS8 understand how application extensions work

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.