Implementing OC and Swift in Swift

Source: Internet
Author: User

In Swift to refer to the OC header file (import), you can use a mixed method, here in SQLite as an example, using Oc-swift Bridge to implement the Add header file
1 introducing the library file of the SQLite database

Open the project configuration file and add Sqlite3 to the third option in the Build Phases Options tab


2. Create a bridge file Command + N key Select Create header file

Write a name

The file to be introduced will be introduced in this header bridge file, and the import statement will be written here.

3 Configuring bridging files
Open the Project profile and enter bridge in the Build Setting Options tab search box to the Objective-c bridging header option. In the options, configure the path to the header file you just created (project name + header filename).

Verify that the function of the integrated OC in Swift is implemented, go to the Appdelegate.swift file and enter SQLite, if prompted, prove that the mixed OC in Swift succeeds, otherwise, the failure

Implementing OC and Swift in Swift

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.