From 955aff1c701b1f44e71b9566eeaefa1da5c984a2 Mon Sep 17 00:00:00 2001 From: PhilCai Date: Sun, 22 Jan 2017 14:26:30 -0800 Subject: [PATCH] fix issue 433 Summary: - [ ] All tests pass. Demo project builds and runs. - [ ] I added tests, an experiment, or detailed why my change isn't tested. - [x] I added an entry to the `CHANGELOG.md` for any breaking changes, enhancements, or bug fixes. - [x] I have reviewed the [contributing guide](https://github.com/Instagram/IGListKit/blob/master/.github/CONTRIBUTING.md) Closes https://github.com/Instagram/IGListKit/pull/436 Differential Revision: D4448494 Pulled By: rnystrom fbshipit-source-id: 09bfdff37dbe0ee718e9e8feb486204e1f55893a --- Source/Internal/IGListSectionMap.m | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Source/Internal/IGListSectionMap.m b/Source/Internal/IGListSectionMap.m index b0d2a1b1..afa80005 100644 --- a/Source/Internal/IGListSectionMap.m +++ b/Source/Internal/IGListSectionMap.m @@ -14,7 +14,7 @@ @interface IGListSectionMap () // both of these maps allow fast lookups of objects, list objects, and indexes -@property (nonatomic, strong, readonly) NSMapTable *, id> *sectionControllerToObjectMap; +@property (nonatomic, strong, readonly) NSMapTable *> *objectToSectionControllerMap; @property (nonatomic, strong, readonly) NSMapTable *, NSNumber *> *sectionControllerToSectionMap; @property (nonatomic, strong, readwrite) NSArray *objects; @@ -27,7 +27,7 @@ IGParameterAssert(mapTable != nil); if (self = [super init]) { - _sectionControllerToObjectMap = [mapTable copy]; + _objectToSectionControllerMap = [mapTable copy]; // lookup list objects by pointer equality _sectionControllerToSectionMap = [[NSMapTable alloc] initWithKeyOptions:NSMapTableStrongMemory | NSMapTableObjectPointerPersonality @@ -49,7 +49,7 @@ } - (IGListSectionController *)sectionControllerForSection:(NSInteger)section { - return [self.sectionControllerToObjectMap objectForKey:[self objectForSection:section]]; + return [self.objectToSectionControllerMap objectForKey:[self objectForSection:section]]; } - (void)updateWithObjects:(NSArray *)objects sectionControllers:(NSArray *)sectionControllers { @@ -64,14 +64,14 @@ // set the index of the list for easy reverse lookup [self.sectionControllerToSectionMap setObject:@(idx) forKey:sectionController]; - [self.sectionControllerToObjectMap setObject:sectionController forKey:object]; + [self.objectToSectionControllerMap setObject:sectionController forKey:object]; }]; } - (nullable IGListSectionController *)sectionControllerForObject:(id)object { IGParameterAssert(object != nil); - return [self.sectionControllerToObjectMap objectForKey:object]; + return [self.objectToSectionControllerMap objectForKey:object]; } - (id)objectForSection:(NSInteger)section { @@ -96,7 +96,7 @@ - (void)reset { [self.sectionControllerToSectionMap removeAllObjects]; - [self.sectionControllerToObjectMap removeAllObjects]; + [self.objectToSectionControllerMap removeAllObjects]; } - (void)updateObject:(id)object { @@ -104,7 +104,7 @@ const NSUInteger section = [self sectionForObject:object]; id sectionController = [self sectionControllerForObject:object]; [self.sectionControllerToSectionMap setObject:@(section) forKey:sectionController]; - [self.sectionControllerToObjectMap setObject:sectionController forKey:object]; + [self.objectToSectionControllerMap setObject:sectionController forKey:object]; NSMutableArray *mobjects = [self.objects mutableCopy]; mobjects[section] = object; @@ -130,7 +130,7 @@ #pragma mark - NSCopying - (id)copyWithZone:(NSZone *)zone { - IGListSectionMap *copy = [[IGListSectionMap allocWithZone:zone] initWithMapTable:self.sectionControllerToObjectMap]; + IGListSectionMap *copy = [[IGListSectionMap allocWithZone:zone] initWithMapTable:self.objectToSectionControllerMap]; copy->_sectionControllerToSectionMap = [self.sectionControllerToSectionMap copy]; copy->_objects = [self.objects copy]; return copy;