ios - RLMObjects not recognised as the same in Realm Cocoa -
i have tableview containing rlmobjects , want search row containing specific rlmobject. after casting rlmresult object original type not same original object:
// ... adding todoa !iscompleted defaultrealm() var firstitem = todo.objectswhere("iscompleted == false")[0] as! todo if firstitem == todoa { // todoa != firstitem even-though should same object }
how can compare 2 rlmobjects without having implement primarykey allocation?
rlmobject
not conform swift's equatable
protocol, allowing ==
, !=
comparisons. depending on equality semantics want objects, can use following extension on rlmobject
:
extension rlmobject: equatable {} func == <t: rlmobject>(lhs: t, rhs: t) -> bool { return lhs.isequaltoobject(rhs) }