Hybrid programming of Swift and OC

Source: Internet
Author: User

Reference Link: http://blog.csdn.net/huangchentao/article/details/35278663

1. Establishment of an OC project (Mixtureocandswift)

2. Create a class of OC (OcTest)

3. Created a swift class (swifttest) when creating this class, Xcode prompts you to create a mixtureocandswift-bridging-header.h file, select Create

4. If you want to use Swifttest in Octest:

?4.1-> in Mixtureocandswift-bridging-header.h add #import "OcTest.h" (this must be added, otherwise, the following report to find the wrong header file)

???4.2-> add Mixtureocandswift-swift.h to the OCTEST.M (if there is no previous step, there will be no warning and error)

???4.3-> can now use Swifttest directly in the octest.

5. If you want to use Octest in Swifttest

? ? ? 5.1-> add #import "OcTest.h" in Mixtureocandswift-bridging-header.h (4.1 has been added, so this can be omitted)

? ? ? 5.2-> can now use Octest directly in the swifttest.

Hybrid programming of Swift and OC

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.