Hi π
How to implement equals method from shared code in swift? The problem is when shared code use operator β==β for 2 similar objects from swift it will return false.
Shared:
Copy code
interface SharedInterface {
val propertyA: Int
}
class SharedService() {
fun equals(actual: SharedInterface, expected: SharedInterface){
return actual.equals(expected)
}
}
Swift:
Copy code
final class SharedInterfaceImpl: SharedInterface, Equatable {
let propertyA: Int
static func == (lhs: SharedInterfaceImpl, rhs: SharedInterfaceImpl) -> Bool {
lhs.propertyA == rhs.propertyA
}
}
// some code in iOS main class
let actual = SharedInterfaceImpl(1)
let expected = SharedInterfaceImpl(1)
print(actual == expected) // true
print(SharedService().equals(actual, expected)) //false