Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mixing objective-c and swift when subclassing

People also ask

Can you mix Objective-C and Swift?

You can use Objective-C and Swift files together in a single project, no matter which language the project used originally. This makes creating mixed-language app and framework targets as straightforward as creating an app or framework target written in a single language.

Can Objective-C class inherit from Swift?

Swift classes that are inherited from OBJC classes are bridged automatically. That means any class inherited from, for example, UIViewController is automatically seen in the OBJC runtime. If you're creating a class that doesn't inherit from anything, then make it an NSObject subclass, as you would in OBJC.

How do you subclass a Swift class in Objective-C?

Unfortunately, it's not possible to subclass a Swift class in Objective-C. Straight from the docs: You cannot subclass a Swift class in Objective-C. See Apple's guide on interoperability for more details on what you can and cannot access with Objective-C.

Can you call Swift from Objective-C?

The Swift library cannot be directly called from Objective-C, since it is missing the required annotations in the code, and in many cases, modules do not inherit from NSObject, rather they use the native Swift data types.


You cannot subclass a Swift class in Objective-C.

Excerpt from Using Swift with Cocoa and Objective-C


You cannot subclass a Swift class in Objective-C. cf. towards the end of this section of the docs:

However, note that you cannot subclass a Swift class in Objective-C.