Objective-c the things that interact with JavaScript

Source: Internet
Author: User

Tag: Port lock based on ASC core IDG a dot Val

Http://www.cocoachina.com/ios/20160127/15105.html

Recently, the company's operations to engage in a blind activity, its activities to provide data support services, the Web front-end in the public account as the main operating positions, and iOS, Android to provide the corresponding portals and pages to match. An activity that uses the various end of the program ape. And in the face of technology is mainly related to Web-side and server-side interaction, web front-end and iOS, Android interaction. I as an IOS developer, today chat about the Web, IOS, Android three-terminal interaction, in fact, the white point is the method of mutual invocation. The main explanation here is iOS. Android will slightly mention it for reference only.

The logical diagram of this article

Figure 0-0 The logical diagram of this article

Overview

iOS native Apps and Web pages interact roughly in these ways iOS7 after the JavaScriptCore, intercept protocol, third-party framework Webviewjavascriptbridge, IOS8 after the wkwebview here mainly to explain the JavaScriptCore and interception protocol two ways. Webviewjavascriptbridge is an encapsulation based on the interception protocol. The study cost is relatively javascriptcore higher, the use also is inferior javascriptcore convenient This article does not narrate. Wkwebview is iOS8 after the launch, has not become mainstream use, so this article does not do a detailed description.

Ios

The iOS side writes code based on the method name defined by the front end, but sometimes the Web front end lets us define it, but when we define it, he's going to change it again. So when it comes to three-terminal interaction, it's best to have the Web front-end define the method name, and iOS and Android write code based on the Web front-end definition. JavaScriptCore in the Web page call native application method can be used delegate or block two methods, this article to be explained by delegate.

JavaScriptCore Classes and protocols:

    • Jscontext: Provides a context for JavaScript to run

    • Bridges of Jsvalue:javascript and objective-c data and methods

    • Jsmanagedvalue: Classes for managing data and methods

    • Jsvirtualmachine: Handling thread-related, using less

    • Jsexport: This is an agreement that, if you interact with a protocol, your own defined protocol must comply with this Protocol

Objective-c the things that interact with JavaScript

Related Article

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.