Proper parameters for closeAllDocumentsWithDelegate - swift

I am writing an app that needs to have multiple documents in one window (as was asked about here. So I can't just make it a "document-based application", but I am still trying to use the document architecture to save the individual files.
What I'm specifically trying to do is close all open documents, and preferably save them if they have been modified. It seems like the best way to do this is to call the closeAllDocumentsWithDelegate method of the shared document controller. But I don't know what parameters to pass it. The docs say it is:
func closeAllDocumentsWithDelegate(_ delegate: AnyObject?,
didCloseAllSelector didCloseAllSelector: Selector,
contextInfo contextInfo: UnsafeMutablePointer)
They don't say what these mean, though. What delegate, selector and contextInfo should I be calling? I can't find examples of this method being used successfully. I tried seeing if I could get away with self and nil just to get it to compile:
SharedDocumentController.sharedDocumentController().closeAllDocumentsWithDelegate(self, didCloseAllSelector: nil, contextInfo: nil)
But then I get the error "Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)", which I'm told is a null pointer exception. So at least one of those nils is a no-go, probably because of a forced unwrap somewhere. Fine, but what would I put there instead?
EDIT: as requested below, I am attaching a pic of the stacktrace:
And of the console:
2016-06-29 12:00:46.397 FourthDraftBrouillon[54275:6093667] An uncaught exception was raised
2016-06-29 12:00:46.397 FourthDraftBrouillon[54275:6093667] *** -[__NSArray0 objectAtIndex:]: index 2 beyond bounds for empty NSArray
2016-06-29 12:00:46.398 FourthDraftBrouillon[54275:6093667] (
0 CoreFoundation 0x00007fff981034f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff888b8f7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff98123205 -[__NSArray0 objectAtIndex:] + 101
3 libswiftCore.dylib 0x0000000100075f4d _TFVs12_ArrayBuffer19_getElementSlowPathfSiPs9AnyObject_ + 125
4 libswiftCore.dylib 0x0000000100075370 _TFVs12_ArrayBuffer10getElementfTSi20wasNativeTypeCheckedSb_x + 144
5 libswiftCore.dylib 0x000000010008e60a _TFSag9subscriptFSix + 138
6 FourthDraftBrouillon 0x0000000100007c6f _TFC20FourthDraftBrouillon14ViewController14collectionViewfTCSo16NSCollectionView35itemForRepresentedObjectAtIndexPathCSo11NSIndexPath_CSo20NSCollectionViewItem + 799
7 FourthDraftBrouillon 0x0000000100007e2f _TToFC20FourthDraftBrouillon14ViewController14collectionViewfTCSo16NSCollectionView35itemForRepresentedObjectAtIndexPathCSo11NSIndexPath_CSo20NSCollectionViewItem + 79
8 AppKit 0x00007fff92bc40f6 -[_NSCollectionViewDataSourceAdapter collectionView:itemForRepresentedObjectAtIndexPath:] + 487
9 UIFoundation 0x00007fff95acd3ff -[_NSCollectionViewCore _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 81
10 UIFoundation 0x00007fff95ace6f6 -[_NSCollectionViewCore _updateVisibleCellsNow:] + 2167
11 UIFoundation 0x00007fff95ad0b24 -[_NSCollectionViewCore _layoutItems] + 208
12 AppKit 0x00007fff92bb76aa -[NSCollectionView layout] + 80
13 AppKit 0x00007fff923f14eb -[NSView _doLayout] + 53
14 AppKit 0x00007fff923f11a3 -[NSView _layoutSubtreeWithOldSize:] + 324
15 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
16 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
17 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
18 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
19 AppKit 0x00007fff923f06dc -[NSView layoutSubtreeIfNeeded] + 950
20 AppKit 0x00007fff92410025 -[NSWindow(NSConstraintBasedLayout) _layoutViewTree] + 82
21 AppKit 0x00007fff92482603 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 244
22 AppKit 0x00007fff92b191f5 ___NSWindowGetDisplayCycleObserver_block_invoke6358 + 218
23 AppKit 0x00007fff924945fc __37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 719
24 QuartzCore 0x00007fff91702f71 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 85
25 QuartzCore 0x00007fff9170242c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 160
26 QuartzCore 0x00007fff917020ec _ZN2CA11Transaction6commitEv + 508
27 AppKit 0x00007fff925d9650 -[_NSScrollingConcurrentMainThreadSynchronizer _synchronize:completionHandler:] + 391
28 AppKit 0x00007fff925d9496 __80-[_NSScrollingConcurrentMainThreadSynchronizer initWithSharedData:constantData:]_block_invoke + 144
29 libdispatch.dylib 0x00000001005cbcc5 _dispatch_client_callout + 8
30 libdispatch.dylib 0x00000001005deba6 _dispatch_source_latch_and_call + 3387
31 libdispatch.dylib 0x00000001005d0cd8 _dispatch_source_invoke + 978
32 libdispatch.dylib 0x00000001005e3012 _dispatch_main_queue_callback_4CF + 1153
33 CoreFoundation 0x00007fff980b89e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
34 CoreFoundation 0x00007fff980778dd __CFRunLoopRun + 1949
35 CoreFoundation 0x00007fff98076ed8 CFRunLoopRunSpecific + 296
36 HIToolbox 0x00007fff89e0b935 RunCurrentEventLoopInMode + 235
37 HIToolbox 0x00007fff89e0b76f ReceiveNextEventCommon + 432
38 HIToolbox 0x00007fff89e0b5af _BlockUntilNextEventMatchingListInModeWithFilter + 71
39 AppKit 0x00007fff9233cefa _DPSNextEvent + 1067
40 AppKit 0x00007fff9233c32a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
41 AppKit 0x00007fff92330e84 -[NSApplication run] + 682
42 AppKit 0x00007fff922fa46c NSApplicationMain + 1176
43 FourthDraftBrouillon 0x0000000100008d04 main + 84
44 libdyld.dylib 0x00007fff930135ad start + 1
45 ??? 0x0000000000000003 0x0 + 3
)
2016-06-29 12:00:46.399 FourthDraftBrouillon[54275:6093667] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 2 beyond bounds for empty NSArray'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff981034f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff888b8f7e objc_exception_throw + 48
2 CoreFoundation 0x00007fff98123205 -[__NSArray0 objectAtIndex:] + 101
3 libswiftCore.dylib 0x0000000100075f4d _TFVs12_ArrayBuffer19_getElementSlowPathfSiPs9AnyObject_ + 125
4 libswiftCore.dylib 0x0000000100075370 _TFVs12_ArrayBuffer10getElementfTSi20wasNativeTypeCheckedSb_x + 144
5 libswiftCore.dylib 0x000000010008e60a _TFSag9subscriptFSix + 138
6 FourthDraftBrouillon 0x0000000100007c6f _TFC20FourthDraftBrouillon14ViewController14collectionViewfTCSo16NSCollectionView35itemForRepresentedObjectAtIndexPathCSo11NSIndexPath_CSo20NSCollectionViewItem + 799
7 FourthDraftBrouillon 0x0000000100007e2f _TToFC20FourthDraftBrouillon14ViewController14collectionViewfTCSo16NSCollectionView35itemForRepresentedObjectAtIndexPathCSo11NSIndexPath_CSo20NSCollectionViewItem + 79
8 AppKit 0x00007fff92bc40f6 -[_NSCollectionViewDataSourceAdapter collectionView:itemForRepresentedObjectAtIndexPath:] + 487
9 UIFoundation 0x00007fff95acd3ff -[_NSCollectionViewCore _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 81
10 UIFoundation 0x00007fff95ace6f6 -[_NSCollectionViewCore _updateVisibleCellsNow:] + 2167
11 UIFoundation 0x00007fff95ad0b24 -[_NSCollectionViewCore _layoutItems] + 208
12 AppKit 0x00007fff92bb76aa -[NSCollectionView layout] + 80
13 AppKit 0x00007fff923f14eb -[NSView _doLayout] + 53
14 AppKit 0x00007fff923f11a3 -[NSView _layoutSubtreeWithOldSize:] + 324
15 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
16 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
17 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
18 AppKit 0x00007fff923f13ff -[NSView _layoutSubtreeWithOldSize:] + 928
19 AppKit 0x00007fff923f06dc -[NSView layoutSubtreeIfNeeded] + 950
20 AppKit 0x00007fff92410025 -[NSWindow(NSConstraintBasedLayout) _layoutViewTree] + 82
21 AppKit 0x00007fff92482603 -[NSWindow(NSConstraintBasedLayout) layoutIfNeeded] + 244
22 AppKit 0x00007fff92b191f5 ___NSWindowGetDisplayCycleObserver_block_invoke6358 + 218
23 AppKit 0x00007fff924945fc __37+[NSDisplayCycle currentDisplayCycle]_block_invoke + 719
24 QuartzCore 0x00007fff91702f71 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 85
25 QuartzCore 0x00007fff9170242c _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 160
26 QuartzCore 0x00007fff917020ec _ZN2CA11Transaction6commitEv + 508
27 AppKit 0x00007fff925d9650 -[_NSScrollingConcurrentMainThreadSynchronizer _synchronize:completionHandler:] + 391
28 AppKit 0x00007fff925d9496 __80-[_NSScrollingConcurrentMainThreadSynchronizer initWithSharedData:constantData:]_block_invoke + 144
29 libdispatch.dylib 0x00000001005cbcc5 _dispatch_client_callout + 8
30 libdispatch.dylib 0x00000001005deba6 _dispatch_source_latch_and_call + 3387
31 libdispatch.dylib 0x00000001005d0cd8 _dispatch_source_invoke + 978
32 libdispatch.dylib 0x00000001005e3012 _dispatch_main_queue_callback_4CF + 1153
33 CoreFoundation 0x00007fff980b89e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
34 CoreFoundation 0x00007fff980778dd __CFRunLoopRun + 1949
35 CoreFoundation 0x00007fff98076ed8 CFRunLoopRunSpecific + 296
36 HIToolbox 0x00007fff89e0b935 RunCurrentEventLoopInMode + 235
37 HIToolbox 0x00007fff89e0b76f ReceiveNextEventCommon + 432
38 HIToolbox 0x00007fff89e0b5af _BlockUntilNextEventMatchingListInModeWithFilter + 71
39 AppKit 0x00007fff9233cefa _DPSNextEvent + 1067
40 AppKit 0x00007fff9233c32a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
41 AppKit 0x00007fff92330e84 -[NSApplication run] + 682
42 AppKit 0x00007fff922fa46c NSApplicationMain + 1176
43 FourthDraftBrouillon 0x0000000100008d04 main + 84
44 libdyld.dylib 0x00007fff930135ad start + 1
45 ??? 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException

This method simply executes -canCloseDocumentWithDelegate:shouldCloseSelector:contextInfo: for all open windows. So look at its documentation. (Linked above.)
The short form: You can pass a delegate object, which will be informed about the close request via the method that responds to the selector, you passed.
So let's say, the object that should be informed is the app delegate, then you pass this as delegate parameter and write a method in the app delegate, whose selector you pass as selector parameter. In Swift you must decorate that method (Swift: function) with #objc.
The contextInfo is any user-definable data to pass or not. It is simply passed through. It is a "communication channel" from caller in your code to the delegate method, i. e. signaling the reason for the close. You can pass nil for it.
Even I did not test it, but typically you can pass nil for delegate, too. In such a case you should be able to pass NULL (it is no type) for the selector. Just try it. Then you do not need an empty method.

Related

-[SKEmitterNode scaleMode]: unrecognized selector sent to instance 0x6000007b9a40

I'm trying to get a particle effect across my whole background in storyboards using a SpriteKit view that I added but this keeps making my app crash. I tried to add it by code but this aswell crashed my app and I don't really know what to make out of the error message as I can't find much about it on the internet...
I linked my SpriteKit view with my 'MyParticle.sks' file
Full error message:
2021-06-23 14:23:28.897788+0200 Project-drink[31447:7030317] Metal API Validation Enabled
2021-06-23 14:23:29.348537+0200 Project-drink[31447:7030317] -[SKEmitterNode scaleMode]: unrecognized selector sent to instance 0x6000007b9a40
2021-06-23 14:23:29.356132+0200 Project-drink[31447:7030317] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SKEmitterNode scaleMode]: unrecognized selector sent to instance 0x6000007b9a40'
*** First throw call stack:`0 CoreFoundation 0x00007fff20422fba __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff20193ff5 objc_exception_throw + 48
2 CoreFoundation 0x00007fff20431d2f +[NSObject(NSObject) instanceMethodSignatureForSelector:] + 0
3 UIKitCore 0x00007fff246f60f1 -[UIResponder doesNotRecognizeSelector:] + 292
4 CoreFoundation 0x00007fff204274cf ___forwarding___ + 1455
5 CoreFoundation 0x00007fff204297a8 _CF_forwarding_prep_0 + 120
6 SpriteKit 0x00007fff3b47b1e4 -[SKView presentScene:] + 268
7 SpriteKit 0x00007fff3b47c350 -[SKView initWithCoder:] + 1123
8 UIFoundation 0x00007fff23a13ebe UINibDecoderDecodeObjectForValue + 707
9 UIFoundation 0x00007fff23a14148 UINibDecoderDecodeObjectForValue + 1357
10 UIFoundation 0x00007fff23a13bee -[UINibDecoder decodeObjectForKey:] + 244
11 UIKitCore 0x00007fff24be5ead -[UIView initWithCoder:] + 1390
12 UIFoundation 0x00007fff23a13ebe UINibDecoderDecodeObjectForValue + 707
13 UIFoundation 0x00007fff23a13bee -[UINibDecoder decodeObjectForKey:] + 244
14 UIKitCore 0x00007fff242ba159 -[UIRuntimeConnection initWithCoder:] + 160
15 UIFoundation 0x00007fff23a13ebe UINibDecoderDecodeObjectForValue + 707
16 UIFoundation 0x00007fff23a14148 UINibDecoderDecodeObjectForValue + 1357
17 UIFoundation 0x00007fff23a13bee -[UINibDecoder decodeObjectForKey:] + 244
18 UIKitCore 0x00007fff242b4f4a -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 443
19 UIKitCore 0x00007fff242b7a53 -[UINib instantiateWithOwner:options:] + 1122
20 UIKitCore 0x00007fff23f84921 -[UIViewController loadView] + 668
21 UIKitCore 0x00007fff23f84cbc -[UIViewController loadViewIfRequired] + 172
22 UIKitCore 0x00007fff23eba03a -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 162
23 UIKitCore 0x00007fff23eba326 -[UINavigationController _startTransition:fromViewController:toViewController:] + 154
24 UIKitCore 0x00007fff23ebb3b8 -[UINavigationController _startDeferredTransitionIfNeeded:] + 876
25 UIKitCore 0x00007fff23ebc734 -[UINavigationController __viewWillLayoutSubviews] + 150
26 UIKitCore 0x00007fff23e9d04c -[UILayoutContainerView layoutSubviews] + 217
27 UIKitCore 0x00007fff24c18c90 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 2946
28 QuartzCore 0x00007fff27a055b8 -[CALayer layoutSublayers] + 258
29 QuartzCore 0x00007fff27a0be3f _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 611
30 QuartzCore 0x00007fff27a17c53 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 65
31 QuartzCore 0x00007fff27951f26 _ZN2CA7Context18commit_transactionEPNS_11TransactionEdPd + 656
32 QuartzCore 0x00007fff279893b9 _ZN2CA11Transaction6commitEv + 713
33 UIKitCore 0x00007fff246debb8 __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 81
34 CoreFoundation 0x00007fff20390c74 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
35 CoreFoundation 0x00007fff20390070 __CFRunLoopDoBlocks + 437
36 CoreFoundation 0x00007fff2038aa08 __CFRunLoopRun + 892
37 CoreFoundation 0x00007fff2038a1a7 CFRunLoopRunSpecific + 567
38 GraphicsServices 0x00007fff2b874d85 GSEventRunModal + 139
39 UIKitCore 0x00007fff246c14df -[UIApplication _run] + 912
40 UIKitCore 0x00007fff246c639c UIApplicationMain + 101
41 libswiftUIKit.dylib 0x00007fff53fcbf42 $s5UIKit17UIApplicationMainys5Int32VAD_SpySpys4Int8VGGSgSSSgAJtF + 98
42 Project-drink 0x000000010f314c4a $sSo21UIApplicationDelegateP5UIKitE4mainyyFZ + 122
43 Project-drink 0x000000010f314bbe $s13Project_drink11AppDelegateC5$mainyyFZ + 46
44 Project-drink 0x000000010f314ce9 main + 41
45 libdyld.dylib 0x00007fff2025abbd start + 1
)

macCatalyst crash on UIScene in macOS 11 (Big Sur) [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have a macCatalyst app that works perfectly on macOS 10.14, however on upgrading to macOS 11 (Big Sur) both I and my users are complaining that the app crashes on launch. I get an error message "Parameter was not of class UIScene" - do macCatalyst apps now require the use of scenes?
On further inspection, I see the following:
2020-11-28 01:48:40.327810+0000 AppName [13691:435322] *** Assertion failure in -[_UISceneMacHelperUtilities sceneIdentifierForUIScene:], _UISceneMacHelperUtilities.m:83
2020-11-28 01:48:40.336334+0000 AppName[13691:435322] [General] An uncaught exception was raised
2020-11-28 01:48:40.336423+0000 AppName[13691:435322] [General] Parameter was not of class UIScene.
2020-11-28 01:48:40.336545+0000 AppName[13691:435322] [General] (
0 CoreFoundation 0x00007fff204ae6af __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff201e63c9 objc_exception_throw + 48
2 CoreFoundation 0x00007fff204d7512 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff212906c9 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00007fff44a7b2c6 -[_UISceneMacHelperUtilities sceneIdentifierForUIScene:] + 195
5 UIKitMacHelper 0x00007fff34045f74 __46-[UINSApplicationDelegate _setupKeyWindowSync]_block_invoke + 393
6 Foundation 0x00007fff21192d6b -[__NSObserver _doit:] + 287
7 CoreFoundation 0x00007fff20429fdc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
8 CoreFoundation 0x00007fff204c589b ___CFXRegistrationPost_block_invoke + 49
9 CoreFoundation 0x00007fff204c580f _CFXRegistrationPost + 454
10 CoreFoundation 0x00007fff203fabce _CFXNotificationPost + 723
11 Foundation 0x00007fff21166abe -[NSNotificationCenter postNotificationName:object:userInfo:] + 59
12 UIKitCore 0x00007fff44376779 -[UIWindow _makeKeyWindowIgnoringOldKeyWindow:] + 567
13 AppName 0x00000001013fe0c0 $s25AppName13SceneDelegateC5scene_13willConnectTo7optionsySo7UISceneC_So0K7SessionCSo0K17ConnectionOptionsCtF + 1520
14 AppName 0x00000001013feaa6 $s25AppName13SceneDelegateC5scene_13willConnectTo7optionsySo7UISceneC_So0K7SessionCSo0K17ConnectionOptionsCtFTo + 118
15 UIKitCore 0x00007fff44221a31 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1463
16 UIKitCore 0x00007fff4421ffb1 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1109
17 UIKitCore 0x00007fff4421ecfe -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 299
18 UIKitCore 0x00007fff4421eb49 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 358
19 FrontBoardServices 0x00007fff317e7312 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 391
20 FrontBoardServices 0x00007fff318045df __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 102
21 FrontBoardServices 0x00007fff317d60c1 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209
22 FrontBoardServices 0x00007fff318042b7 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 354
23 libdispatch.dylib 0x00000001040c50b0 _dispatch_client_callout + 8
24 libdispatch.dylib 0x00000001040c8927 _dispatch_block_invoke_direct + 286
25 FrontBoardServices 0x00007fff317d5fd8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
26 FrontBoardServices 0x00007fff3181e1c3 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 433
27 FrontBoardServices 0x00007fff317d5fa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 22
28 CoreFoundation 0x00007fff204349fc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x00007fff20434964 __CFRunLoopDoSource0 + 180
30 CoreFoundation 0x00007fff204346df __CFRunLoopDoSources0 + 248
31 CoreFoundation 0x00007fff20433111 __CFRunLoopRun + 890
32 CoreFoundation 0x00007fff204326be CFRunLoopRunSpecific + 563
33 HIToolbox 0x00007fff2869efd0 RunCurrentEventLoopInMode + 292
34 HIToolbox 0x00007fff2869edcc ReceiveNextEventCommon + 709
35 HIToolbox 0x00007fff2869eaef _BlockUntilNextEventMatchingListInModeWithFilter + 64
36 AppKit 0x00007fff22c4bf85 _DPSNextEvent + 883
37 AppKit 0x00007fff22c4a74b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1366
38 AppKit 0x00007fff22c3cbda -[NSApplication run] + 586
39 AppKit 0x00007fff22c10f31 NSApplicationMain + 816
40 AppKit 0x00007fff22f0744d _NSApplicationMainWithInfoDictionary + 16
41 UIKitMacHelper 0x00007fff3403332e UINSApplicationMain + 1418
42 UIKitCore 0x00007fff44202e30 UIApplicationMain + 144
43 AppName 0x00000001014da40b main + 75
44 libdyld.dylib 0x00007fff20357631 start + 1
)
2020-11-28 01:48:40.337802+0000 AppName[13691:435322] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Parameter was not of class UIScene.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff204ae6af __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff201e63c9 objc_exception_throw + 48
2 CoreFoundation 0x00007fff204d7512 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff212906c9 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00007fff44a7b2c6 -[_UISceneMacHelperUtilities sceneIdentifierForUIScene:] + 195
5 UIKitMacHelper 0x00007fff34045f74 __46-[UINSApplicationDelegate _setupKeyWindowSync]_block_invoke + 393
6 Foundation 0x00007fff21192d6b -[__NSObserver _doit:] + 287
7 CoreFoundation 0x00007fff20429fdc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
8 CoreFoundation 0x00007fff204c589b ___CFXRegistrationPost_block_invoke + 49
9 CoreFoundation 0x00007fff204c580f _CFXRegistrationPost + 454
10 CoreFoundation 0x00007fff203fabce _CFXNotificationPost + 723
11 Foundation 0x00007fff21166abe -[NSNotificationCenter postNotificationName:object:userInfo:] + 59
12 UIKitCore 0x00007fff44376779 -[UIWindow _makeKeyWindowIgnoringOldKeyWindow:] + 567
13 AppName 0x00000001013fe0c0 $s25AppName13SceneDelegateC5scene_13willConnectTo7optionsySo7UISceneC_So0K7SessionCSo0K17ConnectionOptionsCtF + 1520
14 AppName 0x00000001013feaa6 $s25AppName13SceneDelegateC5scene_13willConnectTo7optionsySo7UISceneC_So0K7SessionCSo0K17ConnectionOptionsCtFTo + 118
15 UIKitCore 0x00007fff44221a31 +[UIScene _sceneForFBSScene:create:withSession:connectionOptions:] + 1463
16 UIKitCore 0x00007fff4421ffb1 -[UIApplication _connectUISceneFromFBSScene:transitionContext:] + 1109
17 UIKitCore 0x00007fff4421ecfe -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 299
18 UIKitCore 0x00007fff4421eb49 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 358
19 FrontBoardServices 0x00007fff317e7312 -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 391
20 FrontBoardServices 0x00007fff318045df __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.176 + 102
21 FrontBoardServices 0x00007fff317d60c1 -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209
22 FrontBoardServices 0x00007fff318042b7 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 354
23 libdispatch.dylib 0x00000001040c50b0 _dispatch_client_callout + 8
24 libdispatch.dylib 0x00000001040c8927 _dispatch_block_invoke_direct + 286
25 FrontBoardServices 0x00007fff317d5fd8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
26 FrontBoardServices 0x00007fff3181e1c3 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 433
27 FrontBoardServices 0x00007fff317d5fa0 -[FBSSerialQueue _performNextFromRunLoopSource] + 22
28 CoreFoundation 0x00007fff204349fc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
29 CoreFoundation 0x00007fff20434964 __CFRunLoopDoSource0 + 180
30 CoreFoundation 0x00007fff204346df __CFRunLoopDoSources0 + 248
31 CoreFoundation 0x00007fff20433111 __CFRunLoopRun + 890
32 CoreFoundation 0x00007fff204326be CFRunLoopRunSpecific + 563
33 HIToolbox 0x00007fff2869efd0 RunCurrentEventLoopInMode + 292
34 HIToolbox 0x00007fff2869edcc ReceiveNextEventCommon + 709
35 HIToolbox 0x00007fff2869eaef _BlockUntilNextEventMatchingListInModeWithFilter + 64
36 AppKit 0x00007fff22c4bf85 _DPSNextEvent + 883
37 AppKit 0x00007fff22c4a74b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1366
38 AppKit 0x00007fff22c3cbda -[NSApplication run] + 586
39 AppKit 0x00007fff22c10f31 NSApplicationMain + 816
40 AppKit 0x00007fff22f0744d _NSApplicationMainWithInfoDictionary + 16
41 UIKitMacHelper 0x00007fff3403332e UINSApplicationMain + 1418
42 UIKitCore 0x00007fff44202e30 UIApplicationMain + 144
43 AppName 0x00000001014da40b main + 75
44 libdyld.dylib 0x00007fff20357631 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Parameter was not of class UIScene.'
terminating with uncaught exception of type NSException

Terminating app due to uncaught exception 'NSInternalInconsistencyException' reason: 'PushKit'

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'PushKit apps that use VoIP push must link either CallKit or IncomingCallNotifications frameworks.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff23baa1ee __exceptionPreprocess + 350
1 libobjc.A.dylib 0x00007fff50864b20 objc_exception_throw + 48
2 CoreFoundation 0x00007fff23ba9f68 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff25614de9 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 PushKit 0x00007fff2af1896f +[PKPushRegistry _checkIfNecessaryVoIPFrameworksAreLinked] + 251
5 PushKit 0x00007fff2af18cdc -[PKPushRegistry _registerForPushType:] + 287
6 PushKit 0x00007fff2af1975f __38-[PKPushRegistry setDesiredPushTypes:]_block_invoke + 240
7 libdispatch.dylib 0x000000010b470d6c _dispatch_client_callout + 8
8 libdispatch.dylib 0x000000010b47f9fd _dispatch_lane_barrier_sync_invoke_and_complete + 132
9 PushKit 0x00007fff2af1964e -[PKPushRegistry setDesiredPushTypes:] + 108
10 Office Phone 0x0000000109752139 $s12Office_Phone18MainViewControllerC5coderACSgSo7NSCoderC_tcfc + 2857
11 Office Phone 0x00000001097524e3 $s12Office_Phone18MainViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 51
12 UIKitCore 0x00007fff471e7350 -[UIClassSwapper initWithCoder:] + 2427
13 UIFoundation 0x00007fff46a37cd6 UINibDecoderDecodeObjectForValue + 744
14 UIFoundation 0x00007fff46a379e1 -[UINibDecoder decodeObjectForKey:] + 251
15 UIKitCore 0x00007fff471eb657 -[UIRuntimeConnection initWithCoder:] + 125
16 UIFoundation 0x00007fff46a37cd6 UINibDecoderDecodeObjectForValue + 744
17 UIFoundation 0x00007fff46a37f7d UINibDecoderDecodeObjectForValue + 1423
18 UIFoundation 0x00007fff46a379e1 -[UINibDecoder decodeObjectForKey:] + 251
19 UIKitCore 0x00007fff471e641e -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 450
20 UIKitCore 0x00007fff471e918d -[UINib instantiateWithOwner:options:] + 1145
21 UIKitCore 0x00007fff476db470 -[UIStoryboard __reallyInstantiateViewControllerWithIdentifier:creator:storyboardSegueTemplate:sender:] + 279
22 Office Phone 0x000000010976d750 $s12Office_Phone11AppDelegateC21selectVCToBedisplayed2vcySo16UIViewControllerCSg_tF + 464
23 Office Phone 0x000000010976d38f $s12Office_Phone11AppDelegateC22setUpInitialRootScreenyyF + 511
24 Office Phone 0x00000001097708ec $s12Office_Phone11AppDelegateC22requestForVerifyDeviceyyFy9Alamofire12DataResponseVyypGcfU_ + 2828
25 Alamofire 0x0000000109b72591 $s9Alamofire11DataRequestC8response5queue0D10Serializer17completionHandlerACXDSo012OS_dispatch_E0CSg_xyAA0B8ResponseVy16SerializedObjectQzGctAA0bkF8ProtocolRzlFyycfU_yycfU_ + 369
26 Alamofire 0x0000000109b2c22d $sIeg_IeyB_TR + 45
27 libdispatch.dylib 0x000000010b46fdf8 _dispatch_call_block_and_release + 12
28 libdispatch.dylib 0x000000010b470d6c _dispatch_client_callout + 8
29 libdispatch.dylib 0x000000010b47ee24 _dispatch_main_queue_callback_4CF + 1500
30 CoreFoundation 0x00007fff23b0ce49 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
31 CoreFoundation 0x00007fff23b07aa9 __CFRunLoopRun + 2329
32 CoreFoundation 0x00007fff23b06e66 CFRunLoopRunSpecific + 438
33 GraphicsServices 0x00007fff38346bb0 GSEventRunModal + 65
34 UIKitCore 0x00007fff47578dd0 UIApplicationMain + 1621
35 Office Phone 0x000000010977320b main + 75
36 libdyld.dylib 0x00007fff516ecd29 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
You need to import CallKit Framework in your project Framework,Libraries, and Embeded Content section.

Using Cocoa NSSavePanel in Sandbox causes Assertion failure

I'm trying to use the NSSavePanel and added this line to my code.
let test = NSSavePanel()
Everytime this code is called the this error appears.
I'm not quite sure what is happening here because I'm only creating a new object.
Any help appreciated.
Thanks!
*** Assertion failure in -[NSVBSavePanel viewWillInvalidate:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1561.20.106/Nav.subproj/OpenAndSavePanelRemote/NSVBOpenAndSavePanels.m:387
2017-12-23 18:11:33.110099+0100 test[27753:1527254] -[NSVBSavePanel init] caught non-fatal NSInternalInconsistencyException 'bridge absent' with backtrace (
0 CoreFoundation 0x00007fff3ca1900b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fff635f7c76 objc_exception_throw + 48
2 CoreFoundation 0x00007fff3ca1eda2 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fff3eb2b260 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4 AppKit 0x00007fff3a1e748e -[NSVBSavePanel viewWillInvalidate:] + 188
5 ViewBridge 0x00007fff60f376f2 -[NSRemoteView invalidate:] + 292
6 ViewBridge 0x00007fff60f44e88 -[NSRemoteView _advanceToConfigPhaseLegacy] + 1111
7 ViewBridge 0x00007fff60f45d1b -[NSRemoteView _viewServiceMarshalProxy:withDetailedErrorHandler:] + 230
8 ViewBridge 0x00007fff60f46104 -[NSRemoteView _viewServiceMarshalProxy:withErrorHandler:] + 78
9 ViewBridge 0x00007fff60f38194 -[NSRemoteView bridge] + 227
10 AppKit 0x00007fff3a1a2e36 -[NSVBSavePanel init] + 292
11 AppKit 0x00007fff3a66fc7e -[NSSavePanel initWithContentRect:styleMask:backing:defer:] + 71
12 AppKit 0x00007fff3a1a3093 -[NSPanel init] + 87
13 test 0x0000000100002933 _T0So11NSSavePanelCABycfcTO + 19
14 test 0x000000010000131c _T0So11NSSavePanelCABycfC + 60
15 test 0x0000000100001285 _T04test14ViewControllerC11viewDidLoadyyF + 85
16 test 0x00000001000013b4 _T04test14ViewControllerC11viewDidLoadyyFTo + 36
17 AppKit 0x00007fff39fc1632 -[NSViewController _sendViewDidLoad] + 97
18 AppKit 0x00007fff39fb806d -[NSViewController _loadViewIfRequired] + 390
19 AppKit 0x00007fff39fb7e9d -[NSViewController view] + 30
20 AppKit 0x00007fff3a13675d -[NSWindow _contentViewControllerChanged] + 109
21 Foundation 0x00007fff3ea99ade -[NSObject(NSKeyValueCoding) setValue:forKey:] + 331
22 AppKit 0x00007fff3a1794b1 -[NSWindow setValue:forKey:] + 111
23 AppKit 0x00007fff3a179415 -[NSIBUserDefinedRuntimeAttributesConnector establishConnection] + 637
24 AppKit 0x00007fff39f45bbd -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1430
25 AppKit 0x00007fff3a04113a -[NSNib _instantiateNibWithExternalNameTable:options:] + 679
26 AppKit 0x00007fff3a040d96 -[NSNib _instantiateWithOwner:options:topLevelObjects:] + 136
27 AppKit 0x00007fff3a797180 -[NSStoryboard instantiateControllerWithIdentifier:] + 236
28 AppKit 0x00007fff39f39ecf NSApplicationMain + 729
29 test 0x0000000100002d0d main + 13
30 libdyld.dylib 0x00007fff641e7115 start + 1
)
Your File Access permissions for the User Selected File type are probably still set to the default Read Only value
Navigate to the 'Capabilities' tab for your target
Set the User Selected File permission to Read/Write
Run your app (the bridge absent error should be gone)

caught non-fatal NSInvalidArgumentExecption in -[NSScrollView reloadData]

I have built a document based app in swift and then I added a NSCollectionView to it with an add button next to it. The button would call a NSOpenPanel and then the icon of the item chosen should appear in the collection view. However, when I click the 'open' button in the NSOpenPanel, the following were printed to the console:
2017-01-30 19:36:54.205343 CookRecipes[5004:203650] -[NSScrollView reloadData]: unrecognized selector sent to instance 0x6180001c1770
2017-01-30 19:36:54.224746 CookRecipes[5004:203650] -[NSVBSavePanel didEndPanelWithReturnCode:] caught non-fatal NSInvalidArgumentException '-[NSScrollView reloadData]: unrecognized selector sent to instance 0x6180001c1770' with backtrace (
0 CoreFoundation 0x00007fff9e2010db __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffb2e92a2a objc_exception_throw + 48
2 CoreFoundation 0x00007fff9e281cd4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff9e1742a3 ___forwarding___ + 1059
4 CoreFoundation 0x00007fff9e173df8 _CF_forwarding_prep_0 + 120
5 CookRecipes 0x0000000100004239 _TFFC11CookRecipes8Document7addFileFT_T_U_FSiT_ + 457
6 CookRecipes 0x00000001000047ef _TTRXFo_dSi__XFdCb_dSi__ + 47
7 AppKit 0x00007fff9c0665e4 -[NSVBSavePanel didEndPanelWithReturnCode:] + 68
8 AppKit 0x00007fff9c6ba09d -[NSVBSavePanel completeModeless:] + 74
9 AppKit 0x00007fff9befa721 -[NSVBSavePanel observeValueForKeyPath:ofObject:change:context:] + 597
10 Foundation 0x00007fff9fbcb71d NSKeyValueNotifyObserver + 350
11 Foundation 0x00007fff9fbcafb4 NSKeyValueDidChange + 486
12 Foundation 0x00007fff9fb99e96 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 118
13 ViewBridge 0x00007fffb184c066 __41-[NSViewBridge setObject:forKey:withKVO:]_block_invoke + 447
14 ViewBridge 0x00007fffb18d052b withHintInProgress + 487
15 ViewBridge 0x00007fffb184be83 -[NSViewBridge setObject:forKey:withKVO:] + 1014
16 ViewBridge 0x00007fffb184a95a -[NSViewBridge nonLocalChangeInProgress:block:] + 390
17 ViewBridge 0x00007fffb18aa260 -[NSRemoteViewMarshal exceptionSafeSetRemoteObject:forKey:withReply:] + 256
18 ViewBridge 0x00007fffb18aa3e8 -[NSRemoteViewMarshal setRemoteObject:forKey:withReply:] + 56
19 CoreFoundation 0x00007fff9e1756dc __invoking___ + 140
20 CoreFoundation 0x00007fff9e175561 -[NSInvocation invoke] + 289
21 ViewBridge 0x00007fffb18d052b withHintInProgress + 487
22 ViewBridge 0x00007fffb18d025a __deferNSXPCInvocationOntoMainThread_block_invoke_2 + 233
23 ViewBridge 0x00007fffb1851df2 +[NSViewServiceApplication withHostPID:invoke:] + 46
24 ViewBridge 0x00007fffb18d011d __deferNSXPCInvocationOntoMainThread_block_invoke + 179
25 ViewBridge 0x00007fffb18cfd0a __deferBlockOntoMainThread_block_invoke_2 + 544
26 CoreFoundation 0x00007fff9e19771c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
27 CoreFoundation 0x00007fff9e1789d4 __CFRunLoopDoBlocks + 356
28 CoreFoundation 0x00007fff9e178516 __CFRunLoopRun + 1894
29 CoreFoundation 0x00007fff9e177b54 CFRunLoopRunSpecific + 420
30 HIToolbox 0x00007fff9d702a5c RunCurrentEventLoopInMode + 240
31 HIToolbox 0x00007fff9d702891 ReceiveNextEventCommon + 432
32 HIToolbox 0x00007fff9d7026c6 _BlockUntilNextEventMatchingListInModeWithFilter + 71
33 AppKit 0x00007fff9bca85b4 _DPSNextEvent + 1120
34 AppKit 0x00007fff9c422d6b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2789
35 AppKit 0x00007fff9bc9cf35 -[NSApplication run] + 926
36 AppKit 0x00007fff9bc67850 NSApplicationMain + 1237
37 CookRecipes 0x000000010000c344 main + 84
38 libdyld.dylib 0x00007fffb3774255 start + 1
39 ??? 0x0000000000000003 0x0 + 3
)
2017-01-30 19:36:54.239473 CookRecipes[5004:203650] -[NSVBSavePanel observeValueForKeyPath:ofObject:change:context:] caught non-fatal NSInvalidArgumentException '-[NSScrollView reloadData]: unrecognized selector sent to instance 0x6180001c1770' with backtrace (
0 CoreFoundation 0x00007fff9e2010db __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffb2e92a2a objc_exception_throw + 48
2 CoreFoundation 0x00007fff9e281cd4 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00007fff9e1742a3 ___forwarding___ + 1059
4 CoreFoundation 0x00007fff9e173df8 _CF_forwarding_prep_0 + 120
5 CookRecipes 0x0000000100004239 _TFFC11CookRecipes8Document7addFileFT_T_U_FSiT_ + 457
6 CookRecipes 0x00000001000047ef _TTRXFo_dSi__XFdCb_dSi__ + 47
7 AppKit 0x00007fff9c0665e4 -[NSVBSavePanel didEndPanelWithReturnCode:] + 68
8 AppKit 0x00007fff9c6ba09d -[NSVBSavePanel completeModeless:] + 74
9 AppKit 0x00007fff9befa721 -[NSVBSavePanel observeValueForKeyPath:ofObject:change:context:] + 597
10 Foundation 0x00007fff9fbcb71d NSKeyValueNotifyObserver + 350
11 Foundation 0x00007fff9fbcafb4 NSKeyValueDidChange + 486
12 Foundation 0x00007fff9fb99e96 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:] + 118
13 ViewBridge 0x00007fffb184c066 __41-[NSViewBridge setObject:forKey:withKVO:]_block_invoke + 447
14 ViewBridge 0x00007fffb18d052b withHintInProgress + 487
15 ViewBridge 0x00007fffb184be83 -[NSViewBridge setObject:forKey:withKVO:] + 1014
16 ViewBridge 0x00007fffb184a95a -[NSViewBridge nonLocalChangeInProgress:block:] + 390
17 ViewBridge 0x00007fffb18aa260 -[NSRemoteViewMarshal exceptionSafeSetRemoteObject:forKey:withReply:] + 256
18 ViewBridge 0x00007fffb18aa3e8 -[NSRemoteViewMarshal setRemoteObject:forKey:withReply:] + 56
19 CoreFoundation 0x00007fff9e1756dc __invoking___ + 140
20 CoreFoundation 0x00007fff9e175561 -[NSInvocation invoke] + 289
21 ViewBridge 0x00007fffb18d052b withHintInProgress + 487
22 ViewBridge 0x00007fffb18d025a __deferNSXPCInvocationOntoMainThread_block_invoke_2 + 233
23 ViewBridge 0x00007fffb1851df2 +[NSViewServiceApplication withHostPID:invoke:] + 46
24 ViewBridge 0x00007fffb18d011d __deferNSXPCInvocationOntoMainThread_block_invoke + 179
25 ViewBridge 0x00007fffb18cfd0a __deferBlockOntoMainThread_block_invoke_2 + 544
26 CoreFoundation 0x00007fff9e19771c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
27 CoreFoundation 0x00007fff9e1789d4 __CFRunLoopDoBlocks + 356
28 CoreFoundation 0x00007fff9e178516 __CFRunLoopRun + 1894
29 CoreFoundation 0x00007fff9e177b54 CFRunLoopRunSpecific + 420
30 HIToolbox 0x00007fff9d702a5c RunCurrentEventLoopInMode + 240
31 HIToolbox 0x00007fff9d702891 ReceiveNextEventCommon + 432
32 HIToolbox 0x00007fff9d7026c6 _BlockUntilNextEventMatchingListInModeWithFilter + 71
33 AppKit 0x00007fff9bca85b4 _DPSNextEvent + 1120
34 AppKit 0x00007fff9c422d6b -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2789
35 AppKit 0x00007fff9bc9cf35 -[NSApplication run] + 926
36 AppKit 0x00007fff9bc67850 NSApplicationMain + 1237
37 CookRecipes 0x000000010000c344 main + 84
38 libdyld.dylib 0x00007fffb3774255 start + 1
39 ??? 0x0000000000000003 0x0 + 3
)
I think that the code that the problem is in should be in this segment:
extension Document : AddAttachmentDelegate {
internal func addFile() {
let panel = NSOpenPanel()
panel.allowsMultipleSelection = false
panel.canChooseDirectories = false
panel.canChooseFiles = true
panel.begin { (result) -> Void in
if result == NSModalResponseOK, let resultURL = panel.urls.first {
do {
try self.addAttachmentAtURL(url: resultURL)
self.attachmentsList?.reloadData()
} catch let error as NSError {
if let window = self.windowForSheet {
NSApp.presentError(error, modalFor: window, delegate: nil, didPresent: nil, contextInfo: nil)
} else {
NSApp.presentError(error)
}
}
}
}
}
}
I have no idea what is going on. Hope you can help.
EDIT: attachmentsList is connected by the following:
#IBOutlet weak var attachmentsList: NSCollectionView!