We are using a shinobi data grid with 7 sections to display our data. Since the grid doesn’t have a collapse all functionality, we wrote a loop to close each index. This seems to work fine as long as none of the sections have 13 or more items and you don’t scroll. If this happens, shinobi causes a crash. But this only happens after you scroll for a while. We have 1 section with over 900 items and 1 section with exactly 13. It fails if we don’t include the 900 items as well.
The code we use to collapse all:
- (IBAction)collapseAll:(id)sender {
for (int i = 0; i < self.shinobiDataGrid.numberOfSections; i++)
[self.shinobiDataGrid setSectionAtIndex:i asCollapsed:YES];
}
The stack trace from the console is:
From: ; layer = ; contentOffset: {0, 0}; contentSize: {718, 284}; adjustedContentInset: {0, 0, 0, 0}>
2017-10-26 12:15:24.535760-0400 GTMobile[10357:1634263] *** Terminating app due to uncaught exception 'ShinobiGridsException', reason: 'The method -[ShinobiGrid assertSectionIndexValid:] cannot take an index that does not exist in the ShinobiGrid - section at index 9 does not exist in this ShinobiGrid.
From: ; layer = ; contentOffset: {0, 0}; contentSize: {718, 284}; adjustedContentInset: {0, 0, 0, 0}>'
*** First throw call stack:
(
0 CoreFoundation 0x000000010fcc61cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010f1e2f41 objc_exception_throw + 48
2 GTMobile 0x000000010a18f04d +[ShinobiGridLog fatalLogMessage:fromSource:] + 189
3 GTMobile 0x000000010a148f60 -[ShinobiGrid assertSectionIndexValid:] + 160
4 GTMobile 0x000000010a14940e -[ShinobiGrid sectionAtIndexIsCollapsed:] + 62
5 GTMobile 0x000000010a168b66 -[ShinobiGrid topRowNeedsAddedToVisibleGrid] + 374
6 GTMobile 0x000000010a16a90c -[ShinobiGrid removeRowsFromBottomAddToTopIfNeeded] + 1100
7 GTMobile 0x000000010a1674e6 -[ShinobiGrid tidyRowAndColEdges] + 150
8 GTMobile 0x000000010a154f66 -[ShinobiGrid reloadInternal:] + 486
9 GTMobile 0x000000010a1740ab -[SGridSection tidyAfterCollapseOrExpand] + 59
10 GTMobile 0x000000010a173f04 _60-[SGridSection collapseOrExpandProgrammatic:withCompletion:]block_invoke.148 + 68
11 GTMobile 0x000000010a174b05 _39-[SGridSection collapseWithCompletion:]block_invoke.213 + 85
12 UIKit 0x000000010c5bcc31 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 859
13 UIKit 0x000000010c58f82d -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 354
14 UIKit 0x000000010c58fe6e -[UIViewAnimationState animationDidStop:finished:] + 293
15 QuartzCore 0x000000010bc35ad7 ZN2CA5Layer23runanimation_callbacksEPv + 323
16 libdispatch.dylib 0x000000011175e43c dispatchclient_callout + 8
17 libdispatch.dylib 0x00000001117696f0 dispatchmain_queue_callback_4CF + 628
18 CoreFoundation 0x000000010fc88ef9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
19 CoreFoundation 0x000000010fc4d662 __CFRunLoopRun + 2402
20 CoreFoundation 0x000000010fc4ca89 CFRunLoopRunSpecific + 409
21 GraphicsServices 0x00000001110f69c6 GSEventRunModal + 62
22 UIKit 0x000000010c4f923c UIApplicationMain + 159
23 GTMobile 0x0000000109f664e7 main + 151
24 libdyld.dylib 0x00000001117dad81 start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)