Weak Linking in Swift

Viewed 562

I'm dealing with a scenario where there is an Objective-C class that I am weakly linking:

__attribute__((weak_import))
@interface MyClass : NSObject @end

I'm also using this class in my Swift code:

let myObject : MyClass = MyClass()

However, this always crashes when run in swift_getObjCClassMetadata, even if I'm only casting an object that's already of type MyClass

let myObject : MyClass = otherObj as? MyClass

Is there any way to successfully cast to, or utilize these classes from Swift?

0 Answers
Related