The Swift language released by Apple can exist in one project with the previous objective-c language.
There may be people who think that there can be objective-c or swift in the same class file, which is not right. In the same class file or in the same code block, you can not have both code for both languages, but separate Swift class files or objective-c class files can be called between each other.
Let's talk about how to refer to the Swift class in the Objective-c class and the specific steps for referencing the Objective-c class in the Swift class.
Using Objective-c in Swift
Start by creating a swift iOS project:
Add a objective-c class file, this class is as follows:
While adding the Objective-c file, Xcode prompts you to:
Click Yes!
Use the Objective-c class that you just added in VIEWCONTROLLER.M:
To use Swift in Objective-c, the steps are similar:
Start by creating a objective-c iOS project:
To add a swift class file:
This class is as follows:
Add in Yourproject-bridging-header.h:
Use the Swift class that you just added in VIEWCONTROLLER.M:
Reference Document: Http://stackoverflow.com/questions/24002369/how-to-call-objective-c-code-from-swift
Simultaneous use of objective-c and Swift in the project