IGListDiffable
@protocol IGListDiffable
The IGListDiffable
protocol provides methods needed to compare the identity and equality of two objects.
-
Returns a key that uniquely identifies the object.
Note
Two objects may share the same identifier, but are not equal. A common pattern is to use the
NSObject
category for automatic conformance. However this means that objects will be identified on their pointer value so finding updates becomes impossible.Warning
This value should never be mutated.
Declaration
Objective-C
- (nonnull id<NSObject>)diffIdentifier;
Swift
func diffIdentifier() -> NSObjectProtocol
Return Value
A key that can be used to uniquely identify the object.
-
Returns whether the receiver and a given object are equal.
Declaration
Objective-C
- (BOOL)isEqualToDiffableObject:(nullable id<IGListDiffable>)object;
Swift
func isEqual(toDiffableObject object: ListDiffable?) -> Bool
Parameters
object
The object to be compared to the receiver.
Return Value
YES
if the receiver and object are equal, otherwiseNO
.