Closed shotkee closed 12 months ago
Please show exactly what you're trying to do. I don't quite understand the relation between invoke
and { "some_param1": "1231", "some_param2": null}
. Are you trying to send a struct as a parameter? If so, show how you defined your struct.
I suppose to use invoke method like this
self.connection?.invoke(method: "SomeServerMethod", "123", NSNull(), "123") { error in }
for invocation data like :
Optional
NSNull
is a foreign concept in Swift and is not supported by default by Encodable, JSONEncoder etc. I haven't tried but I think using just nil
doesn't work because the compiler is not able to figure the generic type. This is why your workaround with creating a variable works - it tells the compiler what type it should expect. I admit it is pretty ugly. But you should be able to reduce the ugliness by invoking this method like this:
self.connection?.invoke(method: "SomeServerMethod", "123", nil as String?, "123") { error in }
thank you for explanation
Some solution for "requires that 'NSNull' conform to 'Encodable'" error for hub connection invoke method for param output like { "some_param1": "1231", "some_param2": null} please