Mixed programming of Ios-swift and OBJECT-C

Source: Internet
Author: User

1. PrefaceIt turns out that Swift could not replace object-c in a short period of time, and .... The Apple Swift development team said: "we ' ll recommend people start with Swift, sure, but OBJC ' t going anywhere.   Our goal's to work with the platform, not reinvent."well, Apple's official attitude towards Swift and OBJC is clear and ready to learn two languages at the same time. So the first thing we will do is a mix of two languages programming, today easy to get started-2.Swift calling Object-c code2.1. Create a swift project2.2. Create a Object-c classThis will show whether you need to create a the header of the OC BridgeAnd then we choose Yes here is sure to create and then write a simple method in OC class2.3. Import the OC file header file into the bridge file If you do not import, there will be no prompt in the swift file, and you cannot call2.4. Create an object in the Swift file, runThe SayHello method was called successfully.3.object-c calling Swift code3.1. Create a OBJECT-C project3.2. Create a Swift classThis will still show if you need to create a header for the OC Bridge, and then we'll choose yes here's what we're going to create.2.3. bridge Files

Here and Swift call OC different focus, need attention

This is what Swift is actively using to invoke the OC language. Here we are OC invoke Swift language, so do not import the Swift file in this bridge file_____________ for what ? because it was created, Xcode also created a hidden file and this hidden file is the imperative for our OC to invoke Swift language. So what's his name? "Project Engineering name" + "-" + "Swift". HWe need to import this hidden file in OC class, although we can't see it, but it actually exists.2.4. Create an object in the OC file, run Note: Here OC creates the object and sometimes it appears when the method is called--Call the method when there is no hint, or even error said that the method is not found at this time we do not have to run the fact that the operation is successful, and then the error message disappears as follows: The call SayHello method succeeds. Thank you, what questions can be commented on the proposed, I have time to reply patiently!Clear Saup
Source: http://www.cnblogs.com/qingche/
This article is copyright to the author and the blog Park is shared, welcome reprint, but must retain this paragraph statement, and in the article page obvious location to give the original text connection.

Mixed programming of Ios-swift and OBJECT-C

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.