Skip to content

Commit 65a5e6d

Browse files
Ryan Nystromfacebook-github-bot
Ryan Nystrom
authored andcommitted
Fix binding SC deselection crash and publish 3.1.1
Summary: - Fixed #918 by checking `respondsToSelector:` (boo optionals) - Cut 3.1.1 for immediate publish - [x] All tests pass. Demo project builds and runs. - [x] 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. Closes #921 Differential Revision: D5748009 Pulled By: rnystrom fbshipit-source-id: b387b3988abc785f312bc47ac003851283972d7a
1 parent 0ad49e1 commit 65a5e6d

File tree

67 files changed

+161
-89
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+161
-89
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

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

5+
3.1.1
6+
-----
7+
8+
### Fixes
9+
10+
- 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)
11+
512
3.1.0
613
-----
714

Examples/Examples-iOS/Podfile.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PODS:
2-
- IGListKit (3.1.0):
3-
- IGListKit/Default (= 3.1.0)
4-
- IGListKit/Default (3.1.0):
2+
- IGListKit (3.1.1):
3+
- IGListKit/Default (= 3.1.1)
4+
- IGListKit/Default (3.1.1):
55
- IGListKit/Diffing
6-
- IGListKit/Diffing (3.1.0)
6+
- IGListKit/Diffing (3.1.1)
77

88
DEPENDENCIES:
99
- IGListKit (from `../../IGListKit.podspec`)
@@ -13,7 +13,7 @@ EXTERNAL SOURCES:
1313
:path: ../../IGListKit.podspec
1414

1515
SPEC CHECKSUMS:
16-
IGListKit: 5065cb595903016ca42ed52fc0f9cd3b13170bff
16+
IGListKit: cb97f405ae43e59fe1da74271e19427ec20d3c07
1717

1818
PODFILE CHECKSUM: 0d505f6895c1f8c0016d78680f9b532c444cbb5e
1919

Examples/Examples-iOS/Pods/Local Podspecs/IGListKit.podspec.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-iOS/Pods/Manifest.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-iOS/Pods/Target Support Files/IGListKit/Info.plist

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-macOS/Podfile.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PODS:
2-
- IGListKit (3.1.0):
3-
- IGListKit/Default (= 3.1.0)
4-
- IGListKit/Default (3.1.0):
2+
- IGListKit (3.1.1):
3+
- IGListKit/Default (= 3.1.1)
4+
- IGListKit/Default (3.1.1):
55
- IGListKit/Diffing
6-
- IGListKit/Diffing (3.1.0)
6+
- IGListKit/Diffing (3.1.1)
77

88
DEPENDENCIES:
99
- IGListKit (from `../../IGListKit.podspec`)
@@ -13,7 +13,7 @@ EXTERNAL SOURCES:
1313
:path: ../../IGListKit.podspec
1414

1515
SPEC CHECKSUMS:
16-
IGListKit: 5065cb595903016ca42ed52fc0f9cd3b13170bff
16+
IGListKit: cb97f405ae43e59fe1da74271e19427ec20d3c07
1717

1818
PODFILE CHECKSUM: bbe5708b3a7f2dd7c70bb14225a7e37f67e1de58
1919

Examples/Examples-macOS/Pods/Local Podspecs/IGListKit.podspec.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-macOS/Pods/Manifest.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-macOS/Pods/Target Support Files/IGListKit/Info.plist

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-tvOS/Podfile.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
PODS:
2-
- IGListKit (3.1.0):
3-
- IGListKit/Default (= 3.1.0)
4-
- IGListKit/Default (3.1.0):
2+
- IGListKit (3.1.1):
3+
- IGListKit/Default (= 3.1.1)
4+
- IGListKit/Default (3.1.1):
55
- IGListKit/Diffing
6-
- IGListKit/Diffing (3.1.0)
6+
- IGListKit/Diffing (3.1.1)
77

88
DEPENDENCIES:
99
- IGListKit (from `../../IGListKit.podspec`)
@@ -13,7 +13,7 @@ EXTERNAL SOURCES:
1313
:path: ../../IGListKit.podspec
1414

1515
SPEC CHECKSUMS:
16-
IGListKit: 5065cb595903016ca42ed52fc0f9cd3b13170bff
16+
IGListKit: cb97f405ae43e59fe1da74271e19427ec20d3c07
1717

1818
PODFILE CHECKSUM: f68cec0d93efa38d42ede50dfe01309d83664d56
1919

Examples/Examples-tvOS/Pods/Local Podspecs/IGListKit.podspec.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-tvOS/Pods/Manifest.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Examples/Examples-tvOS/Pods/Target Support Files/IGListKit/Info.plist

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

IGListKit.podspec

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'IGListKit'
3-
s.version = '3.1.0'
3+
s.version = '3.1.1'
44
s.summary = 'A data-driven UICollectionView framework.'
55
s.homepage = 'https://github.com/Instagram/IGListKit'
66
s.documentation_url = 'https://instagram.github.io/IGListKit'

IGListKit.xcodeproj/project.pbxproj

+8
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,8 @@
235235
298DDA3B1E3B16F800F76F50 /* IGLayoutTestDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 298DDA271E3B166100F76F50 /* IGLayoutTestDataSource.m */; };
236236
298DDA3C1E3B170300F76F50 /* IGLayoutTestSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 298DDA2B1E3B166100F76F50 /* IGLayoutTestSection.m */; };
237237
298DDA3D1E3B170400F76F50 /* IGLayoutTestSection.m in Sources */ = {isa = PBXBuildFile; fileRef = 298DDA2B1E3B166100F76F50 /* IGLayoutTestSection.m */; };
238+
2995409E1F588C9400F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */; };
239+
2995409F1F588C9500F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */; };
238240
2997D4971DF5FC0B005A5DD2 /* IGReloadDataUpdaterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 2997D4961DF5FC0B005A5DD2 /* IGReloadDataUpdaterTests.m */; };
239241
29C4748C1DDF45F400AE68CE /* IGListAdapterProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C4748A1DDF45E700AE68CE /* IGListAdapterProxyTests.m */; };
240242
29C4748D1DDF45F900AE68CE /* IGListAdapterProxyTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 29C4748A1DDF45E700AE68CE /* IGListAdapterProxyTests.m */; };
@@ -483,6 +485,8 @@
483485
298DDA291E3B166100F76F50 /* IGLayoutTestItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGLayoutTestItem.m; sourceTree = "<group>"; };
484486
298DDA2A1E3B166100F76F50 /* IGLayoutTestSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGLayoutTestSection.h; sourceTree = "<group>"; };
485487
298DDA2B1E3B166100F76F50 /* IGLayoutTestSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGLayoutTestSection.m; sourceTree = "<group>"; };
488+
2995409A1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGTestBindingWithoutDeselectionDelegate.h; sourceTree = "<group>"; };
489+
2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGTestBindingWithoutDeselectionDelegate.m; sourceTree = "<group>"; };
486490
2997D4961DF5FC0B005A5DD2 /* IGReloadDataUpdaterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGReloadDataUpdaterTests.m; sourceTree = "<group>"; };
487491
29C4748A1DDF45E700AE68CE /* IGListAdapterProxyTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IGListAdapterProxyTests.m; sourceTree = "<group>"; };
488492
29DA5C9E1EA7C70400113926 /* IGListGenericSectionController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IGListGenericSectionController.h; sourceTree = "<group>"; };
@@ -840,6 +844,8 @@
840844
298DD9D91E3ADE3300F76F50 /* IGTestStringBindableCell.m */,
841845
88144F051D870EDC007C7F66 /* IGTestSupplementarySource.h */,
842846
88144F061D870EDC007C7F66 /* IGTestSupplementarySource.m */,
847+
2995409A1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.h */,
848+
2995409B1F588C8D00F647CF /* IGTestBindingWithoutDeselectionDelegate.m */,
843849
);
844850
path = Objects;
845851
sourceTree = "<group>";
@@ -1447,6 +1453,7 @@
14471453
885FE23C1DC51B86009CE2B4 /* IGTestCell.m in Sources */,
14481454
298DDA001E3AE28000F76F50 /* IGTestDiffingObject.m in Sources */,
14491455
29C579331DE0DA8A003A149B /* IGTestStoryboardSupplementaryView.m in Sources */,
1456+
2995409F1F588C9500F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */,
14501457
885FE2401DC51B86009CE2B4 /* IGTestSingleItemDataSource.m in Sources */,
14511458
885FE2451DC51B86009CE2B4 /* IGTestStoryboardCell.m in Sources */,
14521459
298DD9CF1E3ADD1400F76F50 /* IGListBindingSectionControllerTests.m in Sources */,
@@ -1555,6 +1562,7 @@
15551562
88144F0C1D870EDC007C7F66 /* IGListDiffTests.m in Sources */,
15561563
8285404C1DE40C6E00118B94 /* IGListTestHorizontalSection.m in Sources */,
15571564
298DDA081E3AE2B100F76F50 /* IGTestNumberBindableCell.m in Sources */,
1565+
2995409E1F588C9400F647CF /* IGTestBindingWithoutDeselectionDelegate.m in Sources */,
15581566
88144F0A1D870EDC007C7F66 /* IGListBatchUpdateDataTests.m in Sources */,
15591567
26271C8C1DAE96740073E116 /* IGListSingleNibItemControllerTests.m in Sources */,
15601568
29DA5CA31EA7C72400113926 /* IGListGenericSectionControllerTests.m in Sources */,

Source/IGListBindingSectionController.m

+4-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ - (void)didSelectItemAtIndex:(NSInteger)index {
124124
}
125125

126126
- (void)didDeselectItemAtIndex:(NSInteger)index {
127-
[self.selectionDelegate sectionController:self didDeselectItemAtIndex:index viewModel:self.viewModels[index]];
127+
id<IGListBindingSectionControllerSelectionDelegate> selectionDelegate = self.selectionDelegate;
128+
if ([selectionDelegate respondsToSelector:@selector(sectionController:didDeselectItemAtIndex:viewModel:)]) {
129+
[selectionDelegate sectionController:self didDeselectItemAtIndex:index viewModel:self.viewModels[index]];
130+
}
128131
}
129132

130133
@end

Source/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>3.1.0</string>
18+
<string>3.1.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

Tests/IGListBindingSectionControllerTests.m

+18
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#import <XCTest/XCTest.h>
1111

12+
#import <OCMock/OCMock.h>
1213
#import <IGListKit/IGListKit.h>
1314

1415
#import "IGTestDiffingDataSource.h"
@@ -20,6 +21,7 @@
2021
#import "IGTestObject.h"
2122
#import "IGTestCell.h"
2223
#import "IGListTestCase.h"
24+
#import "IGTestBindingWithoutDeselectionDelegate.h"
2325

2426
@interface IGListBindingSectionControllerTests : IGListTestCase
2527

@@ -121,6 +123,22 @@ - (void)test_whenDeselectingCell_thatCorrectViewModelSelected {
121123
XCTAssertEqualObjects(section.deselectedViewModel, @"seven");
122124
}
123125

126+
- (void)test_whenDeselectingCell_withoutImplementation_thatNoOps {
127+
[self setupWithObjects:@[
128+
[[IGTestDiffingObject alloc] initWithKey:@1 objects:@[@7, @"seven"]],
129+
]];
130+
131+
IGTestBindingWithoutDeselectionDelegate *delegate = [IGTestBindingWithoutDeselectionDelegate new];
132+
IGTestDiffingSectionController *section = [self.adapter sectionControllerForObject:self.dataSource.objects.firstObject];
133+
section.selectionDelegate = delegate;
134+
135+
[self.adapter collectionView:self.collectionView didDeselectItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]];
136+
XCTAssertFalse(delegate.selected);
137+
138+
[self.adapter collectionView:self.collectionView didSelectItemAtIndexPath:[NSIndexPath indexPathForItem:1 inSection:0]];
139+
XCTAssertTrue(delegate.selected);
140+
}
141+
124142
- (void)test_whenAdapterReloadsObjects_thatSectionUpdated {
125143
[self setupWithObjects:@[
126144
[[IGTestDiffingObject alloc] initWithKey:@1 objects:@[@7, @"seven"]],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) 2016-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import <Foundation/Foundation.h>
11+
12+
#import <IGListKit/IGListKit.h>
13+
14+
@interface IGTestBindingWithoutDeselectionDelegate : NSObject <IGListBindingSectionControllerSelectionDelegate>
15+
16+
@property (nonatomic, assign) BOOL selected;
17+
18+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Copyright (c) 2016-present, Facebook, Inc.
3+
* All rights reserved.
4+
*
5+
* This source code is licensed under the BSD-style license found in the
6+
* LICENSE file in the root directory of this source tree. An additional grant
7+
* of patent rights can be found in the PATENTS file in the same directory.
8+
*/
9+
10+
#import "IGTestBindingWithoutDeselectionDelegate.h"
11+
12+
@implementation IGTestBindingWithoutDeselectionDelegate
13+
14+
- (void)sectionController:(IGListBindingSectionController *)sectionController didSelectItemAtIndex:(NSInteger)index viewModel:(id)viewModel {
15+
self.selected = YES;
16+
}
17+
18+
@end

docs/Classes.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ <h4>Declaration</h4>
867867
</section>
868868
</section>
869869
<section id="footer">
870-
<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>
870+
<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>
871871
<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>
872872
</section>
873873
</article>

docs/Classes/IGListAdapter.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ <h4>Return Value</h4>
15661566
</section>
15671567
</section>
15681568
<section id="footer">
1569-
<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>
1569+
<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>
15701570
<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>
15711571
</section>
15721572
</article>

0 commit comments

Comments
 (0)