Fatal Error when trying to publish to channel from iOS/swift

I am receiving this error:

Thread 1: “[<Backendless.Channel 0x280b367f0> valueForUndefinedKey:]: this class is not key value coding-compliant for the key objectId.”

When I try to publish to default channel (or any channel). Here is code:

Backendless.shared.messaging.publish(channelName: savedT.objectId!, message: "New Thread: \(savedT.threadName)", responseHandler: { messageStatus in
                    print("Thread has been created")
                    
                }, errorHandler: { fault in
                    print("Error: \(fault.message ?? "")")
                })

and for default channel:

Backendless.shared.messaging.publish(channelName: "default", message: "New Thread: \(savedT.threadName)", responseHandler: { messageStatus in
                    print("Thread has been created")
                    
                }, errorHandler: { fault in
                    print("Error: \(fault.message ?? "")")
                })

Hello @David_Thompson,

Unfortunately, I cannot reproduce this issue.
What type the savedT object has? It seems like the error may be related to this object.

Regards,
Olha

Well I thought it had something to do with the Channel class, but it was actually the class of the savedT object. I had added this parameter:

var channel: Channel = Channel(channelName: "")

I was going to store the channel for each messaging thread in the MessageThread object, but when I added this parameter I would get the error mentioned above. I don’t know exactly why that parameter throws that error, but I’m just going to refactor the code so I can remove the parameter from that class.

thank you for checking

Actually I was able to add the parameter back, but had to use it as an optional like this:

var channel: Channel?

this works