Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix binding SC deselection crash and publish 3.1.1 #921

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

The changelog for `IGListKit`. Also see the [releases](https://github.com/instagram/IGListKit/releases) on GitHub.

3.1.1
-----

### Fixes

- Prevent a crash when `IGListBindingSectionControllerDelegate` objects do not implement the optional deselection API. [Ryan Nystrom](https://github.com/rnystrom) [(#921)](https://github.com/Instagram/IGListKit/pull/921)

3.1.0
-----

Expand Down
10 changes: 5 additions & 5 deletions Examples/Examples-iOS/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- IGListKit (3.1.0):
- IGListKit/Default (= 3.1.0)
- IGListKit/Default (3.1.0):
- IGListKit (3.1.1):
- IGListKit/Default (= 3.1.1)
- IGListKit/Default (3.1.1):
- IGListKit/Diffing
- IGListKit/Diffing (3.1.0)
- IGListKit/Diffing (3.1.1)

DEPENDENCIES:
- IGListKit (from `../../IGListKit.podspec`)
Expand All @@ -13,7 +13,7 @@ EXTERNAL SOURCES:
:path: ../../IGListKit.podspec

SPEC CHECKSUMS:
IGListKit: 5065cb595903016ca42ed52fc0f9cd3b13170bff
IGListKit: cb97f405ae43e59fe1da74271e19427ec20d3c07

PODFILE CHECKSUM: 0d505f6895c1f8c0016d78680f9b532c444cbb5e

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Examples/Examples-iOS/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Examples/Examples-macOS/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- IGListKit (3.1.0):
- IGListKit/Default (= 3.1.0)
- IGListKit/Default (3.1.0):
- IGListKit (3.1.1):
- IGListKit/Default (= 3.1.1)
- IGListKit/Default (3.1.1):
- IGListKit/Diffing
- IGListKit/Diffing (3.1.0)
- IGListKit/Diffing (3.1.1)

DEPENDENCIES:
- IGListKit (from `../../IGListKit.podspec`)
Expand All @@ -13,7 +13,7 @@ EXTERNAL SOURCES:
:path: ../../IGListKit.podspec

SPEC CHECKSUMS:
IGListKit: 5065cb595903016ca42ed52fc0f9cd3b13170bff
IGListKit: cb97f405ae43e59fe1da74271e19427ec20d3c07

PODFILE CHECKSUM: bbe5708b3a7f2dd7c70bb14225a7e37f67e1de58

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Examples/Examples-macOS/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Examples/Examples-tvOS/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- IGListKit (3.1.0):
- IGListKit/Default (= 3.1.0)
- IGListKit/Default (3.1.0):
- IGListKit (3.1.1):
- IGListKit/Default (= 3.1.1)
- IGListKit/Default (3.1.1):
- IGListKit/Diffing
- IGListKit/Diffing (3.1.0)
- IGListKit/Diffing (3.1.1)

DEPENDENCIES:
- IGListKit (from `../../IGListKit.podspec`)
Expand All @@ -13,7 +13,7 @@ EXTERNAL SOURCES:
:path: ../../IGListKit.podspec

SPEC CHECKSUMS:
IGListKit: 5065cb595903016ca42ed52fc0f9cd3b13170bff
IGListKit: cb97f405ae43e59fe1da74271e19427ec20d3c07

PODFILE CHECKSUM: f68cec0d93efa38d42ede50dfe01309d83664d56

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Examples/Examples-tvOS/Pods/Manifest.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion IGListKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'IGListKit'
s.version = '3.1.0'
s.version = '3.1.1'
s.summary = 'A data-driven UICollectionView framework.'
s.homepage = 'https://github.com/Instagram/IGListKit'
s.documentation_url = 'https://instagram.github.io/IGListKit'
Expand Down
8 changes: 8 additions & 0 deletions IGListKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@
298DDA3B1E3B16F800F76F50 /* IGLayoutTestDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 298DDA271E3B166100F76F50 /* IGLayoutTestDataSource.m */; };
298DDA3C1E3B170300F76F50 /* IGLayoutTestSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 298DDA2B1E3B166100F76F50 /* IGLayoutTestSection.m */; };
298DDA3D1E3B170400F76F50 /* IGLayoutTestSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 298DDA2B1E3B166100F76F50 /* IGLayoutTestSection.m */; };
2995409E1F588C9400F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */; };
2995409F1F588C9500F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */; };
2997D4971DF5FC0B005A5DD2 /* IGReloadDataUpdaterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2997D4961DF5FC0B005A5DD2 /* IGReloadDataUpdaterTests.m */; };
29C4748C1DDF45F400AE68CE /* IGListAdapterProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C4748A1DDF45E700AE68CE /* IGListAdapterProxyTests.m */; };
29C4748D1DDF45F900AE68CE /* IGListAdapterProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C4748A1DDF45E700AE68CE /* IGListAdapterProxyTests.m */; };
Expand Down Expand Up @@ -483,6 +485,8 @@
298DDA291E3B166100F76F50 /* IGLayoutTestItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGLayoutTestItem.m; sourceTree = "<group>"; };
298DDA2A1E3B166100F76F50 /* IGLayoutTestSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGLayoutTestSection.h; sourceTree = "<group>"; };
298DDA2B1E3B166100F76F50 /* IGLayoutTestSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGLayoutTestSection.m; sourceTree = "<group>"; };
2995409A1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGTestBindingWithoutDeselectionDelegate.h; sourceTree = "<group>"; };
2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGTestBindingWithoutDeselectionDelegate.m; sourceTree = "<group>"; };
2997D4961DF5FC0B005A5DD2 /* IGReloadDataUpdaterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGReloadDataUpdaterTests.m; sourceTree = "<group>"; };
29C4748A1DDF45E700AE68CE /* IGListAdapterProxyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListAdapterProxyTests.m; sourceTree = "<group>"; };
29DA5C9E1EA7C70400113926 /* IGListGenericSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGListGenericSectionController.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -840,6 +844,8 @@
298DD9D91E3ADE3300F76F50 /* IGTestStringBindableCell.m */,
88144F051D870EDC007C7F66 /* IGTestSupplementarySource.h */,
88144F061D870EDC007C7F66 /* IGTestSupplementarySource.m */,
2995409A1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.h */,
2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */,
);
path = Objects;
sourceTree = "<group>";
Expand Down Expand Up @@ -1447,6 +1453,7 @@
885FE23C1DC51B86009CE2B4 /* IGTestCell.m in Sources */,
298DDA001E3AE28000F76F50 /* IGTestDiffingObject.m in Sources */,
29C579331DE0DA8A003A149B /* IGTestStoryboardSupplementaryView.m in Sources */,
2995409F1F588C9500F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */,
885FE2401DC51B86009CE2B4 /* IGTestSingleItemDataSource.m in Sources */,
885FE2451DC51B86009CE2B4 /* IGTestStoryboardCell.m in Sources */,
298DD9CF1E3ADD1400F76F50 /* IGListBindingSectionControllerTests.m in Sources */,
Expand Down Expand Up @@ -1555,6 +1562,7 @@
88144F0C1D870EDC007C7F66 /* IGListDiffTests.m in Sources */,
8285404C1DE40C6E00118B94 /* IGListTestHorizontalSection.m in Sources */,
298DDA081E3AE2B100F76F50 /* IGTestNumberBindableCell.m in Sources */,
2995409E1F588C9400F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */,
88144F0A1D870EDC007C7F66 /* IGListBatchUpdateDataTests.m in Sources */,
26271C8C1DAE96740073E116 /* IGListSingleNibItemControllerTests.m in Sources */,
29DA5CA31EA7C72400113926 /* IGListGenericSectionControllerTests.m in Sources */,
Expand Down
5 changes: 4 additions & 1 deletion Source/IGListBindingSectionController.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,10 @@ - (void)didSelectItemAtIndex:(NSInteger)index {
}

- (void)didDeselectItemAtIndex:(NSInteger)index {
[self.selectionDelegate sectionController:self didDeselectItemAtIndex:index viewModel:self.viewModels[index]];
id<IGListBindingSectionControllerSelectionDelegate> selectionDelegate = self.selectionDelegate;
if ([selectionDelegate respondsToSelector:@selector(sectionController:didDeselectItemAtIndex:viewModel:)]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actual fix here

[selectionDelegate sectionController:self didDeselectItemAtIndex:index viewModel:self.viewModels[index]];
}
}

@end
2 changes: 1 addition & 1 deletion Source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>3.1.0</string>
<string>3.1.1</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
18 changes: 18 additions & 0 deletions Tests/IGListBindingSectionControllerTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#import <XCTest/XCTest.h>

#import <OCMock/OCMock.h>
#import <IGListKit/IGListKit.h>

#import "IGTestDiffingDataSource.h"
Expand All @@ -20,6 +21,7 @@
#import "IGTestObject.h"
#import "IGTestCell.h"
#import "IGListTestCase.h"
#import "IGTestBindingWithoutDeselectionDelegate.h"

@interface IGListBindingSectionControllerTests : IGListTestCase

Expand Down Expand Up @@ -121,6 +123,22 @@ - (void)test_whenDeselectingCell_thatCorrectViewModelSelected {
XCTAssertEqualObjects(section.deselectedViewModel, @"seven");
}

- (void)test_whenDeselectingCell_withoutImplementation_thatNoOps {
[self setupWithObjects:@[
[[IGTestDiffingObject alloc] initWithKey:@1 objects:@[@7, @"seven"]],
]];

IGTestBindingWithoutDeselectionDelegate *delegate = [IGTestBindingWithoutDeselectionDelegate new];
IGTestDiffingSectionController *section = [self.adapter sectionControllerForObject:self.dataSource.objects.firstObject];
section.selectionDelegate = delegate;

[self.adapter collectionView:self.collectionView didDeselectItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W/out fix, tests crash here

XCTAssertFalse(delegate.selected);

[self.adapter collectionView:self.collectionView didSelectItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]];
XCTAssertTrue(delegate.selected);
}

- (void)test_whenAdapterReloadsObjects_thatSectionUpdated {
[self setupWithObjects:@[
[[IGTestDiffingObject alloc] initWithKey:@1 objects:@[@7, @"seven"]],
Expand Down
18 changes: 18 additions & 0 deletions Tests/Objects/IGTestBindingWithoutDeselectionDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import <Foundation/Foundation.h>

#import <IGListKit/IGListKit.h>

@interface IGTestBindingWithoutDeselectionDelegate : NSObject <IGListBindingSectionControllerSelectionDelegate>

@property (nonatomic, assign) BOOL selected;

@end
18 changes: 18 additions & 0 deletions Tests/Objects/IGTestBindingWithoutDeselectionDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/

#import "IGTestBindingWithoutDeselectionDelegate.h"

@implementation IGTestBindingWithoutDeselectionDelegate

- (void)sectionController:(IGListBindingSectionController *)sectionController didSelectItemAtIndex:(NSInteger)index viewModel:(id)viewModel {
self.selected = YES;
}

@end
2 changes: 1 addition & 1 deletion docs/Classes.html
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2017 <a class="link" href="https://twitter.com/fbOpenSource" target="_blank" rel="external">Instagram</a>. All rights reserved. (Last updated: 2017-08-23)</p>
<p>&copy; 2017 <a class="link" href="https://twitter.com/fbOpenSource" target="_blank" rel="external">Instagram</a>. All rights reserved. (Last updated: 2017-08-31)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Classes/IGListAdapter.html
Original file line number Diff line number Diff line change
Expand Up @@ -1566,7 +1566,7 @@ <h4>Return Value</h4>
</section>
</section>
<section id="footer">
<p>&copy; 2017 <a class="link" href="https://twitter.com/fbOpenSource" target="_blank" rel="external">Instagram</a>. All rights reserved. (Last updated: 2017-08-23)</p>
<p>&copy; 2017 <a class="link" href="https://twitter.com/fbOpenSource" target="_blank" rel="external">Instagram</a>. All rights reserved. (Last updated: 2017-08-31)</p>
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.8.3</a>, a <a class="link" href="http://realm.io" target="_blank" rel="external">Realm</a> project.</p>
</section>
</article>
Expand Down
Loading