IOS Swift Project OC and swift Mix, file mutual references

Source: Internet
Author: User

After creating a swift project, if you want to create a new OC file later, a appname-bridging-header.h file is generated

One, in the Swift file

1> Referencing Swift files

Nothing needs to be done, and in all swift files, you can use each other.

2> Referencing OC Files

The OC header file to be referenced is imported into the Appname-bridging-header.h file and can be used in all swift files

Second, in the OC file

1> Referencing Swift files

The swift language-created project automatically generates a appname-swift.h file that contains the header files for all swift files, so using the Swift class in an OC file simply imports the Appname-swift.h file, which is #import " Appname-swift.h ", then you can use all Swift classes in this OC file

2> Referencing OC Files

Import the header file to use the OC file eg. #import "UsedOcFile.h"

Summarize

Calling the OC Code Invoke Swift code
Swift file Dependent Appname-bridging-header.h No need to declare
OC file #import "OC.h" #import "Appname-swift.h

IOS Swift Project OC and swift Mix, file mutual references

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.