1. Calling Swift in the OBJECT-C project
1.1. Create a OBJECT-C project (project name for example: Yydemo) as
1.2. Create a swift Class, such as
This shows whether you need to create a header for the OC Bridge, and then we select the Create
PS: Bridge file
Unlike the SWIFT call OC, it is important to note the following
This is required by Swift to invoke the OC language and import the Object-c file into this bridge file
Here we are OC invoke Swift language, so do not import the Swift file in this bridge file
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.
Calling Object-c in a 2.Swift project
2.1. Create a Swift Project
2.2 Creating a Object-c class
The same will show if you need to create a header for the OC Bridge, and then we choose Create.
2.3 Importing OC files into a bridge file
If you do not import, there will be no prompt in the swift file, and you cannot call
2.4. Create an object in the Swift file, run
Object-c and Swift