I am trying to create a function that has a function pointer with generic parameter but without any success.
I have following code
func connect<T>(object: UnsafeMutablePointer<T>, handler: @convention(c) UnsafeMutablePointer<T> -> Void) {
}But when I try to compile it I get an error: @convention(c) type is not representable in Objective-C
If I change a type to UnsafeMutablePointer<Void> -> Void then it works but then I lose safety of generics. I don't see a reason why it cannot be represented in ObjC? Because in ObjC it can be represented with Void while keeping safety in Swift.
Is there any workaround or do you know why it doesn't work?