简体   繁体   中英

How to use class with same name from objective c instead of swift

Unfortunately, I have a class defined in Objective C (Class.h, Class.m) and another class, with the same name in Swift(Class.swift).

I have a bridging header, where I import the class

#import "Class.h"

Now, I want to create a method that returns the class from Objective C. Is there a way to specify that I want to use the Objective C class instead of the swift one, or should I start renaming my classes?

Rename classes. I am not 100% how Swift classes that are not tagged @objc are treated, but nothing good can come of having two classes with the same name, even if they're written in different languages. If the Swift version is visible to the Objective-C side, you have a definite problem, and you cannot be sure when instantiate a Class which one you will get. It could theoretically change on every run of the program, though in practice the class loader is probably too deterministic for that to occur.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM