I have an Objective-C method that accepts a parameter of type id
and I want to pass it a Swift struct.
ObjcClass.m
file:
@implementation ObjcClass
+ (void)addListener:(id)listener {
// Do something with listener
}
DemoStruct.swift
file:
struct DemoStruct {
func registerAsListener() {
ObjcClass.addListener(self) // Can't find a way to do this
}
}
The compile error message I get:
Type 'DemoStruct' does not conform to protocol 'AnyObject'
So my question would be, how do I make an Objective-C method accept Any
instead of AnyObject
and is there such a thing?