Closed PhilCai1993 closed 7 years ago
@PhilCai1993 hmm good point. To be honest, the reload updater is there basically just for unit tests, and predates the diffing stuff being a core part of IGListKit (used to be its own library).
Ya we should update the map used by the reload updater to account for diffing identifier and diffable equality. In fact, we should just remove that API entirely from the IGListAdapterUpdater
and create the NSMapTable
w/ lookup functions in IGListSectionMap.
I'm not saying it's a bug. But since you say reload updater is basically for unit tests, I'm wondering whether it could be used just for reloadData
in production use?
I resolved this by checking this issue.
@interface ManToken:NSObject<IGListDiffable>
@property Man *man;
@end
And using self
as diffIdentifier
and NSObject
's default isEqual:
as isEqualToDiffableObject:
. This avoids Mantle
's equality and hash functions.
Recently I came across a trouble using
IGListReloadDataUpdater
with Mantle đWhen I'm fetching data from server, for example, searching with a keyword. Everytime when I got a JSON array, it's mapped using MTLModel in
Mantle
.JSON:
If keywords are equal, the JSON is equal. But when mapped to subclass of
MTLModel
, the results are only semantically equal, with different pointers.But MTLModel has implemented its own
hash
andisEqual:
.IGListReloadDataUpdater
usesNSPointerFunctionsObjectPersonality
asobjectLookupPointerFunctions
. SosectionControllerForObject:
inIGListSectionMap
doesn't return nil, it returns something.For example: First time: I got
[Man<0x140fadd30>, Man<0x140fadd31>]
, then performupdate..., collectionview refresh.â Second time: I got[Man<0x140fadd32>, Man<0x140fadd33>]
.then performupdate..., because[<0x140fadd30> isEqual:<0x140fadd32>]
and[<0x140fadd31> isEqual:<0x140fadd33>]
(hashes are equal too). When -[IGListAdapter updateObjects:dataSource:] , this line might return some sectionController, and[dataSource listAdapter:self sectionControllerForObject:object]
will not be called.This behavior is a little unexpected. I subclassed
IGListReloadDataUpdater
and override- objectLookupPointerFunctions
usingNSPointerFunctionsObjectPointerPersonality
as a workaround, instead ofNSPointerFunctionsObjectPersonality
.(Actually I copied almost all codes fromIGListReloadDataUpdater
due to subclassing restriction)Because I really want to recreate a sectioncontroller when performupdate... Is it a right way to do that?
Thanks~