Use OC third-party libraries in Swift (take afnetworking as an example)

Source: Internet
Author: User

First of all, you need to import the third-party library into your project to specifically how to import this is not the focus of this article

Not much nonsense directly on

(1) Build an OC controller directly in the project and Xcode will remind you to build a bridging file. Select Create OK see the bottom I created

(2) Determine the use of the bridge header files such as

(3) in the bridge file to write this directly as

(4) Then you can use the library you added in your project. It's that simple.

Here's a look at the instance code of Afnetworking I used in Swift is the data from the homepage of Baidu

Use OC third-party libraries in Swift (take afnetworking as an example)

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.