我收到我的用戶通過郵件崩潰,並且我多次收到同樣的崩潰。用戶可以向我發送有關崩潰發生的崩潰的評論,但是他們中沒有人對此發表任何評論。所以基本上,是一個錯誤,我不知道如何重現發生在十一月的九次。與NSCollectionView發生奇怪的崩潰(NSRangeException)
這個集合視圖是我的程序的重要組成部分,所以大多數用戶可能一直在使用它,導致這種崩潰幾乎從不發生。沒有與macOS版本相關的模式(它發生在不同的版本中)。
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
如果有任何細節我錯過了免費問,但考慮到我不能再現錯誤,這是很難說。
對於集合視圖,請添加數據源方法。重要的一對是collectionView:numberOfItemsInSection:和collectionView:cellForItemAtIndexPath :.它們都使用相同狀態的相同陣列是至關重要的。 – danh
這是來自macOS的內容數組佈局,不使用這些函數。集合視圖的內容僅通過'setContent:'函數進行更改。 – vitormm