Swift and Objective-c Hybrid programming

Source: Internet
Author: User

in the Swift project, you want to add Objective-c library support at the same time or you need to program with Objective-c
Selecting the Objective-c system when adding a new file automatically generates a Xx-bridging-header.h file and then the. h file of the Objective-c file to be referenced in the SWIFT project#import "Xxxx.h"you can reference the methods in OC in the swift file.


If you do not generate the corresponding Bridging-header file when you add an OC file, you can manually add an. h file yourself, and then name Xxx-bridging-header.h, select Swift in the project build settings Complier, edit the contents of the Objective-c Bridge-header item to the newly added Bridging-header file, and note the file path. Generally: projectname/Projectname-bridging-header.h
Well, it's also possible to refer to the OC method in Swift.

Swift and Objective-c Hybrid programming

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.