I receive my users crashes by mail, And I've received that same crash multiple times. Users can send me comments with the crashes explaining how the crash occurred, however none of them said anything about this one. So basically, is a bug which I don't know how to reproduce which happened a nine times only in November.
This collection view is an important part of my program, so most of the users probably use it all the time, leading to the fact that this crash almost never happens. There is no pattern related with the macOS version (it happened in different versions).
Application Specific Information:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array'
terminating with uncaught exception of type NSException
abort() called
Application Specific Backtrace 1:
0 CoreFoundation 0x00007fff8fc7803c __exceptionPreprocess 172
1 libobjc.A.dylib 0x00007fff88e2876e objc_exception_throw 43
2 CoreFoundation 0x00007fff8fb4fbce -[__NSArrayI objectAtIndex:] 190
3 AppKit 0x00007fff8ea54f3e -[NSCollectionViewItem _copyConnectionsOfObject:prototypeItem:toObject:item:] 750
4 AppKit 0x00007fff8ea54c38 -[NSCollectionViewItem _copyConnectionsToItem:] 95
5 AppKit 0x00007fff8ea52e71 -[NSCollectionViewItem copyWithZone:] 487
6 AppKit 0x00007fff8ea52c20 -[NSCollectionView newItemForRepresentedObject:] 68
7 AppKit 0x00007fff8ea527b3 -[NSCollectionView _getItemsToDisplay] 1168
8 AppKit 0x00007fff8ea52205 -[NSCollectionView setContent:] 217
9 MyApp 0x000000010e3ae9d3 MyApp 117203
10 libdispatch.dylib 0x00007fff8cc2e323 _dispatch_call_block_and_release 12
11 libdispatch.dylib 0x00007fff8cc29c13 _dispatch_client_callout 8
12 libdispatch.dylib 0x00007fff8cc35cbf _dispatch_main_queue_callback_4CF 861
13 CoreFoundation 0x00007fff8fbcb3f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 9
14 CoreFoundation 0x00007fff8fb8668f __CFRunLoopRun 2159
15 CoreFoundation 0x00007fff8fb85bd8 CFRunLoopRunSpecific 296
16 HIToolbox 0x00007fff8bae056f RunCurrentEventLoopInMode 235
17 HIToolbox 0x00007fff8bae02ea ReceiveNextEventCommon 431
18 HIToolbox 0x00007fff8bae012b _BlockUntilNextEventMatchingListInModeWithFilter 71
19 AppKit 0x00007fff8e6f49bb _DPSNextEvent 978
20 AppKit 0x00007fff8e6f3f68 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] 346
21 AppKit 0x00007fff8e6e9bf3 -[NSApplication run] 594
22 AppKit 0x00007fff8e666354 NSApplicationMain 1832
23 libdyld.dylib 0x00007fff8ae8a5c9 start 1
If there is any detail that I missed fell free to ask, but considering that I can't reproduce the bug it's very hard to say.
setContent:
function only. - VitorMM