Allow user customization of Touch Bar in macCatalyst - swift

In a catalyst Swift project a UIViewController subclass creates a TouchBar like this:
override func makeTouchBar() -> NSTouchBar? {
let touchBar = NSTouchBar()
touchBar.delegate = self
touchBar.defaultItemIdentifiers = [<<some>>]
touchBar.customizationAllowedItemIdentifiers = [<<more>>]
touchBar.customizationIdentifier = "com.me.myapp.touchbar"
return touchBar
}
The default items show up on the TouchBar, but there is no menu item to customize them.
Reading the TouchBar documentation there are two options:
1: NSApplication
The Customization Menu Item
A user invokes the customization UI for a particular NSTouchBar object, when it is visible in the Touch Bar, by choosing the bar customization menu item. To enable this menu item you must explicitly opt-in, which you can do in the following ways:
If you want the system to automatically name, place, validate, and activate this menu item in your app’s menus, set the isAutomaticCustomizeTouchBarMenuItemEnabled property of your app object (of type NSApplication) to true.
To explicitly place the customization menu item in one of your app’s menus, employ the toggleTouchBarCustomizationPalette(_:) method of your app object. When you do this, the system still names and validates the menu item, and hides it on systems that do not have a Touch Bar.
Trying to do either of those yields a 'NSApplication' is unavailable in Mac Catalyst error.
So after some googling around I found this:
NSClassFromString("NSApplication")?.setValue(true, forKeyPath: "sharedApplication.automaticCustomizeTouchBarMenuItemEnabled")
print(NSClassFromString("NSApplication")?.value(forKeyPath: "sharedApplication.isAutomaticCustomizeTouchBarMenuItemEnabled"))
This compiles and executes fine. It even prints out Optional(1) where there was an Optional(0) before. But the menu item still is not there. I tried this at the point where I generate the TouchBar, where I generate the Menu, and in func application(_, didFinishLaunchingWithOptions), but to no avail.
I cannot get the second one to not give me an error.
2: TouchBar
Curiously the NSTouchBar has the same property, but running
NSTouchBar.isAutomaticCustomizeTouchBarMenuItemEnabled = true
at any point (which compiles, too) yields no difference.
Question
Is this a missing feature or is there a way to achieve it. And if so: how?
Edit
I am customizing the menu bar. Due to an error, setting the same shortcut for two options, causes the following output in Xcode:
2020-02-15 14:08:01.492510+0100 Myapp[71888:2189305] [MenuBuilder] Menu has duplicates --
<_UIImmutableKeyCommand: 0x60000374e700> -> Title: Toggle Center Column Action: executeOptionForKeyCommand: Input: 1 + (UIKeyModifierCommand)
<_UIImmutableKeyCommand: 0x60000374e640> -> Title: Toggle Left Column Action: executeOptionForKeyCommand: Input: 1 + (UIKeyModifierCommand)
Make a symbolic breakpoint at _UIMenuBuilderError to catch this in the debugger.
2020-02-15 14:08:01.492701+0100 Myapp[71888:2189305] *** Assertion failure in -[_UIMenuBuilder _insertMenu:intoParentMenu:newParentMenu:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3901.4.905/UIMenu/UIMenuBuilder.m:456
2020-02-15 14:08:01.492950+0100 Myapp[71888:2189305] [General] inserted menu has duplicate submenu, command or key command, or a key command is missing input or action
2020-02-15 14:08:01.497025+0100 Myapp[71888:2189305] [General] (
0 CoreFoundation 0x00007fff2f3858ab __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6563f805 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2f3aed10 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff31aa7241 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00007fff6d31dded -[_UIMenuBuilder _insertMenu:intoParentMenu:newParentMenu:] + 1426
5 UIKitCore 0x00007fff6d31e9ef -[_UIMenuBuilder insertChildMenu:atStartOfMenuForIdentifier:] + 177
6 Myapp 0x000000010010a87b $s5Myapp11AppDelegateC9buildMenu4withySo13UIMenuBuilder_p_tF + 4987
7 Myapp 0x000000010010b150 $s5Myapp11AppDelegateC9buildMenu4withySo13UIMenuBuilder_p_tFTo + 64
8 UIKitCore 0x00007fff6d31c428 -[UIResponder _buildMenuFromChainWithBuilder:] + 115
9 UIKitCore 0x00007fff6d31c17f -[UIMenuSystem _newBuilderFromResponderChain:] + 72
10 UIKitCore 0x00007fff6d31c114 -[UIMenuSystem _automaticallyRebuildIfNeeded] + 88
11 UIKitCore 0x00007fff6d31c09e -[UIMenuSystem _rootMenu] + 27
12 UIKitCore 0x00007fff6d3144d9 -[_UIMenuBarController _rebuildRootCommandGroup] + 66
13 Foundation 0x00007fff3197ffab -[__NSObserver _doit:] + 296
14 CoreFoundation 0x00007fff2f2ff35f __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
15 CoreFoundation 0x00007fff2f2ff2f3 ___CFXRegistrationPost1_block_invoke + 63
16 CoreFoundation 0x00007fff2f2ff268 _CFXRegistrationPost1 + 372
17 CoreFoundation 0x00007fff2f2feebe ___CFXNotificationPost_block_invoke + 97
18 CoreFoundation 0x00007fff2f2ce7e2 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1575
19 CoreFoundation 0x00007fff2f2cdc82 _CFXNotificationPost + 1351
20 Foundation 0x00007fff319e6048 postQueueNotifications + 718
21 CoreFoundation 0x00007fff2f3090ee __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
22 CoreFoundation 0x00007fff2f309014 __CFRunLoopDoObservers + 457
23 CoreFoundation 0x00007fff2f308832 __CFRunLoopRun + 1514
24 CoreFoundation 0x00007fff2f307bd3 CFRunLoopRunSpecific + 499
25 HIToolbox 0x00007fff2de5d65d RunCurrentEventLoopInMode + 292
26 HIToolbox 0x00007fff2de5d39d ReceiveNextEventCommon + 600
27 HIToolbox 0x00007fff2de5d127 _BlockUntilNextEventMatchingListInModeWithFilter + 64
28 AppKit 0x00007fff2c4cdba4 _DPSNextEvent + 990
29 AppKit 0x00007fff2c4cc380 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
30 AppKit 0x00007fff2c4be09e -[NSApplication run] + 658
31 AppKit 0x00007fff2c490465 NSApplicationMain + 777
32 AppKit 0x00007fff2c7b369c _NSApplicationMainWithInfoDictionary + 16
33 UIKitMacHelper 0x00007fff602de8f1 UINSApplicationMain + 322
34 UIKitCore 0x00007fff6d186273 UIApplicationMain + 2105
35 Myapp 0x000000010010b39b main + 75
36 libdyld.dylib 0x00007fff669ad7fd start + 1
)
2020-02-15 14:08:27.979587+0100 Myapp[71888:2189305] [Layout] Unable to simultaneously satisfy constraints:
(
"<NSAutoresizingMaskLayoutConstraint:0x600002183ac0 h=-&- v=-&- _SC_RESULTS_TABLE.minY == 0 (active, names: _SC_RESULTS_TABLE:0x100dc3140, '|':SCTMenuView:0x100dca2e0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x600002183f70 h=-&- v=-&- V:|-(202)-[_SC_RESULTS_TABLE] (active, names: _SC_RESULTS_TABLE:0x100dc3140, '|':SCTMenuView:0x100dca2e0 )>",
"<NSAutoresizingMaskLayoutConstraint:0x60000217f200 h=--& v=--& SCTMenuView:0x100dca2e0.height == 59 (active)>"
)
Will attempt to recover by breaking constraint
<NSAutoresizingMaskLayoutConstraint:0x600002183f70 h=-&- v=-&- V:|-(202)-[_SC_RESULTS_TABLE] (active, names: _SC_RESULTS_TABLE:0x100dc3140, '|':SCTMenuView:0x100dca2e0 )>
Set the NSUserDefault NSConstraintBasedLayoutVisualizeMutuallyExclusiveConstraints to YES to have -[NSWindow visualizeConstraints:] automatically called when this happens. And/or, set a symbolic breakpoint on LAYOUT_CONSTRAINTS_NOT_SATISFIABLE to catch this in the debugger.
2020-02-15 14:08:29.504823+0100 Myapp[71888:2189305] [MenuBuilder] Menu has duplicates --
<_UIImmutableKeyCommand: 0x60000375e400> -> Title: Toggle Center Column Action: executeOptionForKeyCommand: Input: 1 + (UIKeyModifierCommand)
<_UIImmutableKeyCommand: 0x60000375e340> -> Title: Toggle Left Column Action: executeOptionForKeyCommand: Input: 1 + (UIKeyModifierCommand)
Make a symbolic breakpoint at _UIMenuBuilderError to catch this in the debugger.
2020-02-15 14:08:29.504936+0100 Myapp[71888:2189305] *** Assertion failure in -[_UIMenuBuilder _insertMenu:intoParentMenu:newParentMenu:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore/UIKit-3901.4.905/UIMenu/UIMenuBuilder.m:456
2020-02-15 14:08:29.506015+0100 Myapp[71888:2189305] [General] inserted menu has duplicate submenu, command or key command, or a key command is missing input or action
2020-02-15 14:08:29.514279+0100 Myapp[71888:2189305] [General] (
0 CoreFoundation 0x00007fff2f3858ab __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6563f805 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2f3aed10 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff31aa7241 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 UIKitCore 0x00007fff6d31dded -[_UIMenuBuilder _insertMenu:intoParentMenu:newParentMenu:] + 1426
5 UIKitCore 0x00007fff6d31e9ef -[_UIMenuBuilder insertChildMenu:atStartOfMenuForIdentifier:] + 177
6 Myapp 0x000000010010a87b $s5Myapp11AppDelegateC9buildMenu4withySo13UIMenuBuilder_p_tF + 4987
7 Myapp 0x000000010010b150 $s5Myapp11AppDelegateC9buildMenu4withySo13UIMenuBuilder_p_tFTo + 64
8 UIKitCore 0x00007fff6d31c428 -[UIResponder _buildMenuFromChainWithBuilder:] + 115
9 UIKitCore 0x00007fff6d31c17f -[UIMenuSystem _newBuilderFromResponderChain:] + 72
10 UIKitCore 0x00007fff6d31c114 -[UIMenuSystem _automaticallyRebuildIfNeeded] + 88
11 UIKitCore 0x00007fff6d3cf5aa -[UIMenuSystem _keyCommands] + 27
12 UIKitCore 0x00007fff6d3cf375 -[UIApplication _keyCommands] + 105
13 UIKitCore 0x00007fff6dd17069 -[UIResponder _keyCommandForEvent:target:] + 182
14 UIKitCore 0x00007fff6dd17405 -[UIResponder _keyCommandForEvent:target:] + 1106
15 UIKitCore 0x00007fff6dd17405 -[UIResponder _keyCommandForEvent:target:] + 1106
16 UIKitCore 0x00007fff6dd17405 -[UIResponder _keyCommandForEvent:target:] + 1106
17 UIKitCore 0x00007fff6dd17405 -[UIResponder _keyCommandForEvent:target:] + 1106
18 UIKitCore 0x00007fff6dd17405 -[UIResponder _keyCommandForEvent:target:] + 1106
19 UIKitCore 0x00007fff6e0a36ce -[UIApplication(iOSMacSupport) _physicalKeyEvent:unmodified:shiftModified:commandModified:modifierFlags:isDown:timestampMachAbs:] + 517
20 UIKitCore 0x00007fff6e0a3803 -[UIApplication(iOSMacSupport) _sendKeyEvent:unmodified:shiftModified:commandModified:modifierFlags:isDown:timestampMachAbs:] + 116
21 UIKitCore 0x00007fff6e0a1c38 __58-[UIApplication(iOSMacSupport) _initiateIOSMacConnections]_block_invoke_3.396 + 124
22 UIKitMacHelper 0x00007fff602f4e3c -[UINSInputView _sendKeyEvent:isDown:] + 452
23 UIKitMacHelper 0x00007fff602f4ebd -[UINSInputView keyUp:] + 47
24 AppKit 0x00007fff2c675b98 -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 6512
25 AppKit 0x00007fff2c674005 -[NSWindow(NSEventRouting) sendEvent:] + 349
26 AppKit 0x00007fff2c672ccf -[NSApplication(NSEvent) sendEvent:] + 2739
27 AppKit 0x00007fff2c4be0cf -[NSApplication run] + 707
28 AppKit 0x00007fff2c490465 NSApplicationMain + 777
29 AppKit 0x00007fff2c7b369c _NSApplicationMainWithInfoDictionary + 16
30 UIKitMacHelper 0x00007fff602de8f1 UINSApplicationMain + 322
31 UIKitCore 0x00007fff6d186273 UIApplicationMain + 2105
32 Myapp 0x000000010010b39b main + 75
33 libdyld.dylib 0x00007fff669ad7fd start + 1
)
2020-02-15 14:08:30.338067+0100 Myapp[71888:2189305] *** Assertion failure in -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1894.30.142/AppKit.subproj/NSApplication.m:3694
2020-02-15 14:08:30.338318+0100 Myapp[71888:2189305] [General] Modal session requires modal window
2020-02-15 14:08:30.348833+0100 Myapp[71888:2189305] [General] (
0 CoreFoundation 0x00007fff2f3858ab __exceptionPreprocess + 250
1 libobjc.A.dylib 0x00007fff6563f805 objc_exception_throw + 48
2 CoreFoundation 0x00007fff2f3aed10 +[NSException raise:format:arguments:] + 88
3 Foundation 0x00007fff31aa7241 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
4 AppKit 0x00007fff2c7cf9d0 -[NSApplication _commonBeginModalSessionForWindow:relativeToWindow:modalDelegate:didEndSelector:contextInfo:] + 1583
5 AppKit 0x00007fff2c7cf39b -[NSApplication beginModalSessionForWindow:] + 37
6 AppKit 0x00007fff2c7cf2fc __35-[NSApplication runModalForWindow:]_block_invoke_2 + 39
7 AppKit 0x00007fff2c7cf2c2 __35-[NSApplication runModalForWindow:]_block_invoke + 70
8 AppKit 0x00007fff2c7ceb4c _NSTryRunModal + 100
9 AppKit 0x00007fff2c7cea31 -[NSApplication runModalForWindow:] + 128
10 AppKit 0x00007fff2cd21be6 __82-[NSTouchBarCustomizationController toggleCustomizationPalette:forceControlStrip:]_block_invoke_4 + 148
11 AppKit 0x00007fff2cd244c7 ___NSRunLoopTimerCreateWithHandler_block_invoke + 34
12 CoreFoundation 0x00007fff2f324804 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
13 CoreFoundation 0x00007fff2f3243be __CFRunLoopDoTimer + 859
14 CoreFoundation 0x00007fff2f323e9e __CFRunLoopDoTimers + 317
15 CoreFoundation 0x00007fff2f308aed __CFRunLoopRun + 2213
16 CoreFoundation 0x00007fff2f307bd3 CFRunLoopRunSpecific + 499
17 HIToolbox 0x00007fff2de5d65d RunCurrentEventLoopInMode + 292
18 HIToolbox 0x00007fff2de5d2a9 ReceiveNextEventCommon + 356
19 HIToolbox 0x00007fff2de5d127 _BlockUntilNextEventMatchingListInModeWithFilter + 64
20 AppKit 0x00007fff2c4cdba4 _DPSNextEvent + 990
21 AppKit 0x00007fff2c4cc380 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
22 AppKit 0x00007fff2c4be09e -[NSApplication run] + 658
23 AppKit 0x00007fff2c490465 NSApplicationMain + 777
24 AppKit 0x00007fff2c7b369c _NSApplicationMainWithInfoDictionary + 16
25 UIKitMacHelper 0x00007fff602de8f1 UINSApplicationMain + 322
26 UIKitCore 0x00007fff6d186273 UIApplicationMain + 2105
27 Myapp 0x000000010010b39b main + 75
28 libdyld.dylib 0x00007fff669ad7fd start + 1
)
2020-02-15 14:08:31.815095+0100 Myapp[71888:2189305] [AXRuntimeCommon] Unknown client: Myapp
But then the customize TouchBar action shows up in the menu (all my custom ones are gone), the ❗MISSING LABEL❗ issue is easily fixed.
So I wondered whether it was my menu customization code causing the error, but uncommenting the entire override func buildMenu(with builder: UIMenuBuilder) in my AppDelegate does not cause the customization menu to appear – only the shortcut collision does.

In my Swift Catalyst app (macOS 10.15.3, Xcode 11.3.1), I am able to call
NSTouchBar.isAutomaticCustomizeTouchBarMenuItemEnabled = true
in my override func makeTouchBar() method, and the "Customize Touch Bar..." menu item appears in the "View" menu tab. For the missing labels, the following works:
func touchBar(_ touchBar: NSTouchBar, makeItemForIdentifier identifier: NSTouchBarItem.Identifier) -> NSTouchBarItem? {
if identifier == yourIdentifier {
let item = NSPickerTouchBarItem(...)
item.customizationLabel = "View Segmented Control"
return item
}
return nil
}

Related

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)

How to Convert CGEvent to NSEvent in Swift?

I'm trying to convert CGEvent to NSEvent using NSEvent(cgEvent: event) in order to get the characters of key press, but I get the error saying it's an "Invalid event." My code and the error message are below. Any help would b eappreciated. Thanks!
func myCGEventCallback(proxy : CGEventTapProxy, type : CGEventType, event : CGEvent, refcon : UnsafeMutableRawPointer?) -> Unmanaged<CGEvent>? {
if type == .keyDown {
if let other = NSEvent(cgEvent: event), let chars = other.characters {
debugPrint(chars)
}
}
return Unmanaged.passRetained(event)
}
2017-06-10 23:18:14.233831-0400 RemapEvent[54431:3082409] [default] Invalid event.
2017-06-10 23:18:14.233938-0400 RemapEvent[54431:3082409] *** Assertion failure in -[NSEvent characters], /Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1504.83.101/AppKit.subproj/NSEvent.m:2414
2017-06-10 23:18:14.234153-0400 RemapEvent[54431:3082409] [General] Invalid message sent to event "NSEvent: type=FlagsChanged loc=(580,464.336) time=116091.6 flags=0x40101 win=0x0 winNum=0 ctxt=0x0 keyCode=59"
2017-06-10 23:18:14.234965-0400 RemapEvent[54431:3082409] [General] (
0 CoreFoundation 0x00007fffa16c62cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x00007fffb64d148d objc_exception_throw + 48
2 CoreFoundation 0x00007fffa16cb042 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00007fffa3113c80 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 AppKit 0x00007fff9f2caa64 -[NSEvent characters] + 174
5 RemapEvent 0x0000000100003da9 _TFFC10RemapEvent14ViewController11viewDidLoadFT_T_L_17myCGEventCallbackFT5proxyVs13OpaquePointer4typeOSC11CGEventType5eventCSo7CGEvent6refconGSqSv__GSqGVs9UnmanagedS3___ + 473
6 RemapEvent 0x0000000100004877 _TToFFC10RemapEvent14ViewController11viewDidLoadFT_T_L_17myCGEventCallbackFT5proxyVs13OpaquePointer4typeOSC11CGEventType5eventCSo7CGEvent6refconGSqSv__GSqGVs9UnmanagedS3___ + 55
7 SkyLight 0x00007fffb32c0dca processDecodedEventRef + 204
8 SkyLight 0x00007fffb32c05b4 processEventTapData + 544
9 SkyLight 0x00007fffb319e6db _XPostEventTapData + 280
10 SkyLight 0x00007fffb32c033e eventTapMessageHandler + 137
11 CoreFoundation 0x00007fffa16451ed __CFMachPortPerform + 253
12 CoreFoundation 0x00007fffa16450d9 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 41
13 CoreFoundation 0x00007fffa1645051 __CFRunLoopDoSource1 + 465
14 CoreFoundation 0x00007fffa163ccc5 __CFRunLoopRun + 2389
15 CoreFoundation 0x00007fffa163c114 CFRunLoopRunSpecific + 420
16 HIToolbox 0x00007fffa0b9debc RunCurrentEventLoopInMode + 240
17 HIToolbox 0x00007fffa0b9dcf1 ReceiveNextEventCommon + 432
18 HIToolbox 0x00007fffa0b9db26 _BlockUntilNextEventMatchingListInModeWithFilter + 71
19 AppKit 0x00007fff9f136a54 _DPSNextEvent + 1120
20 AppKit 0x00007fff9f8b27ee -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 2796
21 AppKit 0x00007fff9f12b3db -[NSApplication run] + 926
22 AppKit 0x00007fff9f0f5e0e NSApplicationMain + 1237
23 RemapEvent 0x000000010000648d main + 13
24 libdyld.dylib 0x00007fffb6db6235 start + 1
)

Swift - hierarchy constraint issues and debugging

I'm new to swift and am finding debugging to be particularly difficult. I"m using RubyMotion if that is relevant. After I log out a user and try to log back in I receive the following log:
2017-04-20 13:56:54.810 nav[8614:3232848] *** Assertion failure in -[UIView _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3600.6.21/NSLayoutConstraint_UIKitAdditions.m:649
2017-04-20 13:56:54.927 nav[8614:3232848] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000102ab5d4b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010141421e objc_exception_throw + 48
2 CoreFoundation 0x0000000102ab9e42 +[NSException raise:format:arguments:] + 98
3 Foundation 0x00000001038d466d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x0000000105a4d57b __120-[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]_block_invoke_2 + 206
5 UIKit 0x0000000105a4d417 -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 418
6 UIKit 0x0000000105a4d7e8 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 30
7 UIKit 0x0000000105a4d8fa -[UIView(UIConstraintBasedLayout) _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 221
8 UIKit 0x0000000105a4dc0e __50-[UIView(UIConstraintBasedLayout) addConstraints:]_block_invoke + 208
9 Foundation 0x000000010385a3b0 -[NSISEngine withBehaviors:performModifications:] + 155
10 UIKit 0x0000000105a4db2f -[UIView(UIConstraintBasedLayout) addConstraints:] + 277
11 nav 0x00000001000d2ae2 __unnamed_64 + 98
12 nav 0x00000001004b495c vm_dispatch + 1372
13 nav 0x00000001004b8511 rb_scope__strain__ + 1313
14 nav 0x00000001009d9135 rb_vm_dispatch + 7221
15 nav 0x00000001004b495c vm_dispatch + 1372
16 nav 0x00000001004b7a3e rb_scope__initialize__ + 238
17 nav 0x00000001009d9135 rb_vm_dispatch + 7221
18 nav 0x000000010092ec57 rb_class_new_instance0 + 855
19 nav 0x00000001009d86e6 rb_vm_dispatch + 4582
20 nav 0x000000010076c1ec vm_dispatch + 1372
21 nav 0x0000000100780bc3 rb_scope__main_layout__ + 275
22 nav 0x00000001009d9135 rb_vm_dispatch + 7221
23 nav 0x000000010076c1ec vm_dispatch + 1372
24 nav 0x0000000100777955 rb_scope__layout__ + 133
25 nav 0x00000001009d9135 rb_vm_dispatch + 7221
26 nav 0x000000010076c1ec vm_dispatch + 1372
27 nav 0x0000000100778496 rb_scope__viewDidLoad__ + 534
28 nav 0x00000001007784ed __unnamed_67 + 13
29 UIKit 0x000000010522aa3d -[UIViewController loadViewIfRequired] + 1258
30 UIKit 0x0000000105231062 -[UIViewController __viewWillAppear:] + 118
31 UIKit 0x000000010525c1d3 -[UINavigationController _startCustomTransition:] + 1290
32 UIKit 0x000000010526ce48 -[UINavigationController _startDeferredTransitionIfNeeded:] + 697
33 UIKit 0x000000010526dfdb -[UINavigationController __viewWillLayoutSubviews] + 58
34 UIKit 0x0000000105464dd7 -[UILayoutContainerView layoutSubviews] + 223
35 UIKit 0x000000010514dab8 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
36 QuartzCore 0x0000000104b4ebf8 -[CALayer layoutSublayers] + 146
37 QuartzCore 0x0000000104b42440 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
38 QuartzCore 0x0000000104b422be _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
39 QuartzCore 0x0000000104ad0318 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
40 QuartzCore 0x0000000104afd3ff _ZN2CA11Transaction6commitEv + 475
41 QuartzCore 0x0000000104afdd6f _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
42 CoreFoundation 0x0000000102a5a267 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
43 CoreFoundation 0x0000000102a5a1d7 __CFRunLoopDoObservers + 391
44 CoreFoundation 0x0000000102a3ef8e __CFRunLoopRun + 1198
45 CoreFoundation 0x0000000102a3e884 CFRunLoopRunSpecific + 420
46 GraphicsServices 0x0000000107e57a6f GSEventRunModal + 161
47 UIKit 0x0000000105088c68 UIApplicationMain + 159
48 nav 0x00000001000a9fd2 main + 146
49 libdyld.dylib 0x0000000106f1b68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
What I'm struggling with is trying to find out where the error is in my code from the error logs.
Perhaps I'm spoiled but in ruby I'm used to a filename and line number being given where the error has been caused - is this something I can find out from this log?
Thanks in advance.

Proper parameters for closeAllDocumentsWithDelegate

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.

Invalid pairing of layout attributes when specifying constraints programmatically in code in swift VC

I am following the pattern used in the the example here :
https://github.com/lucasderraugh/AppleProg-Cocoa-Tutorials/blob/master/Lesson%2066/Lesson%2066/AppDelegate.swift
My VC (subclass of NSViewController) looks like this :
import Cocoa
class SecondViewController: NSViewController {
var leftView = ColorView()
var rightView = ColorView()
#IBOutlet weak var nameTextField: NSTextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do view setup here.
}
override func viewDidAppear() {
leftView.translatesAutoresizingMaskIntoConstraints = false
rightView.translatesAutoresizingMaskIntoConstraints = false
let leftConstraints:[NSLayoutConstraint] = [
leftView.widthAnchor.constraintEqualToAnchor(self.view.topAnchor),
leftView.leftAnchor.constraintEqualToAnchor(self.view.leftAnchor),
leftView.widthAnchor.constraintEqualToConstant(100),
leftView.heightAnchor.constraintEqualToConstant(100)
]
self.view.addSubview(leftView)
NSLayoutConstraint.activateConstraints(leftConstraints)
}
override func prepareForSegue(segue: NSStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "SecondToFourthSegue" {
(segue.destinationController as! NSViewController).representedObject = nameTextField.stringValue
}
}
}
But I get the following error at runtime :
Invalid pairing of layout attributes
The full stack trace :
2016-04-26 00:54:06.402 Hyperterm[19046:1591173] An uncaught exception was raised
2016-04-26 00:54:06.403 Hyperterm[19046:1591173] *** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Invalid pairing of layout attributes
2016-04-26 00:54:06.403 Hyperterm[19046:1591173] (
0 CoreFoundation 0x00007fff89cf94f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8b89b73c objc_exception_throw + 48
2 CoreFoundation 0x00007fff89d604bd +[NSException raise:format:] + 205
3 Foundation 0x00007fff8d717f92 VerifyConstraintArguments + 356
4 Foundation 0x00007fff8d717c16 +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 295
5 Foundation 0x00007fff8d71d410 -[NSLayoutAnchor constraintEqualToAnchor:multiplier:constant:] + 149
6 Foundation 0x00007fff8d71e87f -[NSLayoutDimension constraintEqualToAnchor:multiplier:constant:] + 39
7 Hyperterm 0x000000010001bee1 _TFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 385
8 Hyperterm 0x000000010001c4b2 _TToFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 34
9 libdispatch.dylib 0x0000000100607070 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x00000001005f9cc5 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00000001006116ae _dispatch_main_queue_callback_4CF + 2845
12 CoreFoundation 0x00007fff89cae9e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00007fff89c6d8dd __CFRunLoopRun + 1949
14 CoreFoundation 0x00007fff89c6ced8 CFRunLoopRunSpecific + 296
15 HIToolbox 0x00007fff949a7935 RunCurrentEventLoopInMode + 235
16 HIToolbox 0x00007fff949a776f ReceiveNextEventCommon + 432
17 HIToolbox 0x00007fff949a75af _BlockUntilNextEventMatchingListInModeWithFilter + 71
18 AppKit 0x00007fff878aeefa _DPSNextEvent + 1067
19 AppKit 0x00007fff878ae32a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
20 AppKit 0x00007fff878a2e84 -[NSApplication run] + 682
21 AppKit 0x00007fff8786c46c NSApplicationMain + 1176
22 Hyperterm 0x000000010001b724 main + 84
23 libdyld.dylib 0x00007fff8fc285ad start + 1
24 ??? 0x0000000000000003 0x0 + 3
)
2016-04-26 00:54:06.405 Hyperterm[19046:1591173] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:]: Invalid pairing of layout attributes'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff89cf94f2 __exceptionPreprocess + 178
1 libobjc.A.dylib 0x00007fff8b89b73c objc_exception_throw + 48
2 CoreFoundation 0x00007fff89d604bd +[NSException raise:format:] + 205
3 Foundation 0x00007fff8d717f92 VerifyConstraintArguments + 356
4 Foundation 0x00007fff8d717c16 +[NSLayoutConstraint constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:] + 295
5 Foundation 0x00007fff8d71d410 -[NSLayoutAnchor constraintEqualToAnchor:multiplier:constant:] + 149
6 Foundation 0x00007fff8d71e87f -[NSLayoutDimension constraintEqualToAnchor:multiplier:constant:] + 39
7 Hyperterm 0x000000010001bee1 _TFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 385
8 Hyperterm 0x000000010001c4b2 _TToFC9Hyperterm20SecondViewController13viewDidAppearfT_T_ + 34
9 libdispatch.dylib 0x0000000100607070 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x00000001005f9cc5 _dispatch_client_callout + 8
11 libdispatch.dylib 0x00000001006116ae _dispatch_main_queue_callback_4CF + 2845
12 CoreFoundation 0x00007fff89cae9e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00007fff89c6d8dd __CFRunLoopRun + 1949
14 CoreFoundation 0x00007fff89c6ced8 CFRunLoopRunSpecific + 296
15 HIToolbox 0x00007fff949a7935 RunCurrentEventLoopInMode + 235
16 HIToolbox 0x00007fff949a776f ReceiveNextEventCommon + 432
17 HIToolbox 0x00007fff949a75af _BlockUntilNextEventMatchingListInModeWithFilter + 71
18 AppKit 0x00007fff878aeefa _DPSNextEvent + 1067
19 AppKit 0x00007fff878ae32a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
20 AppKit 0x00007fff878a2e84 -[NSApplication run] + 682
21 AppKit 0x00007fff8786c46c NSApplicationMain + 1176
22 Hyperterm 0x000000010001b724 main + 84
23 libdyld.dylib 0x00007fff8fc285ad start + 1
24 ??? 0x0000000000000003 0x0 + 3
)
libc++abi.dylib: terminating with uncaught exception of type NSException
leftView.widthAnchor should not equal to self.view.topAnchor You might not pay attention to it