I have an Objective-C method that takes a type parameter id, and I want to pass a Swift structure to it.
ObjcClass.m file:
@implementation ObjcClass
+ (void)addListener:(id)listener {
}
DemoStruct.swift file:
struct DemoStruct {
func registerAsListener() {
ObjcClass.addListener(self)
}
}
The compilation error message I get:
The type "DemoStruct" does not comply with the protocol "AnyObject"
So my question is: how to make an Objective-C accept method Anyinstead AnyObjectand is there such a thing?
source
share