Hybrid programming in Apple system development (1): mutual calls between Objective-C and C ++, and mutual calls between flex and js

Source: Internet
Author: User

Hybrid programming in Apple system development (1): mutual calls between Objective-C and C ++, and mutual calls between flex and js
First, OC calls the C ++ code. Create an Objective-C Project and create the c ++ file MyCppFile. hpp and MyCppFile. cpp.

Change the file name of the Cpp Code to the mm extension. The structure of the project code is as follows:

 

Code for implementing C ++: MyCppFile. hpp MyCppFile. cpp can be called by introducing the C ++ header file in main. mm:

 

Then, C ++ first creates an OC-related file by calling OC, and then modifies *. m to *. mm.

 

The header file is written in the C format.

Write the specific implementation with OC.

Similarly, you can call it by introducing the header file in C ++.

 

The call between OC and C ++ is simpler than expected. The key here is to change the extension of the OC file to *. mm.

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.