jeudi 31 août 2023

Swift 5 Comparing Object properties

I'm trying to compare two objects to check which properties were updated. I'm using Mirror to list the properties and try the comparison. Code is:

                let mirrorLote = Mirror(reflecting: l)
                let mirrorLoteUpd = Mirror(reflecting: lUpd)
                
                mirrorLote.children.forEach { child in
                    if (child.label != "id") {
                        mirrorLoteUpd.children.forEach { childUpd in
                            if (child.label == childUpd.label && child.value != childUpd.value){
                                addUpdatesDB(prop: child.label, val: childUpd.value)
                            }
                        }
                    }
                }

I'm getting the following error: "Type 'Any' cannot conform to 'RawRepresentable'" when trying to compare the values (child.value != childUpd.value).

Any ideas on how can I resolve this? Thanks!!





Aucun commentaire:

Enregistrer un commentaire