Type objectId but receives string in change listener swift crash

I have a model in collection which has userId of type ObjectId but i received in string format when i get changes initially or update. My app crashes if i set type objectId as when i receive userId in string.

’Expected object of type object id for property ‘userId’ on object of type ‘device_reading’, but received: 6050956d57f60d3225dfccb7’

Hi @Muhammad_Awais could you please share your schema and Object definitions as well as how your creating the objects/documents

I resolved the issue. I was seding wrong wrong data in realm query

realm.objects(SomeObject.self).filter(“userId = ‘string value of id’”)

corrected with :
realm.objects(SomeObject.self).filter(“userId = %@”, ObjectId(“string value of id”))

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.