Have written the func validateRaise
exactly as in the book. I have also checked “validates immediately”. There is no error.
I have checked with println(“Error fired!”) in the validateRaise-method and it doesn’t seem to get called.
Any ideas why?
2015-07-23 15:19:51.081 RaiseMan[2885:1315746] An uncaught exception was raised
2015-07-23 15:19:51.081 RaiseMan[2885:1315746] [<RaiseMan.Employee 0x60800004b820> setNilValueForKey]: could not set nil as the value for the key raise.
2015-07-23 15:19:51.096 RaiseMan[2885:1315746] (
0 CoreFoundation 0x00007fff8c14203c __exceptionPreprocess + 172
1 libobjc.A.dylib 0x00007fff9626c76e objc_exception_throw + 43
2 CoreFoundation 0x00007fff8c141eed +[NSException raise:format:] + 205
3 Foundation 0x00007fff92890e19 -[NSObject(NSKeyValueCoding) setNilValueForKey:] + 81
4 Foundation 0x00007fff92764e7d -[NSObject(NSKeyValueCoding) setValue:forKey:] + 395
5 Foundation 0x00007fff92787901 -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 339
6 Foundation 0x00007fff927878cd -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 287
7 AppKit 0x00007fff8de82703 -[NSView setValue:forKeyPath:] + 387
8 AppKit 0x00007fff8dede074 -[NSBinder _setValue:forKeyPath:ofObject:mode:validateImmediately:raisesForNotApplicableKeys:error:] + 360
9 AppKit 0x00007fff8deddeb3 -[NSBinder setValue:forBinding:error:] + 248
10 AppKit 0x00007fff8e36eb20 -[NSValueBinder _applyObjectValue:forBinding:canRecoverFromErrors:handleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:] + 220
11 AppKit 0x00007fff8e36ee6e -[NSValueBinder applyDisplayedValueHandleErrors:typeOfAlert:canRecoverFromErrors:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:error:] + 566
12 AppKit 0x00007fff8e36f004 -[NSValueBinder _applyDisplayedValueIfHasUncommittedChangesWithHandleErrors:typeOfAlert:discardEditingCallback:otherCallback:callbackContextInfo:didRunAlert:error:] + 128
13 AppKit 0x00007fff8df68ff0 -[NSValueBinder validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:] + 485
14 AppKit 0x00007fff8df68de1 -[_NSBindingAdaptor _validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:bindingAdaptor:] + 162
15 AppKit 0x00007fff8df68d1e -[_NSBindingAdaptor validateAndCommitValueInEditor:editingIsEnding:errorUserInterfaceHandled:] + 246
16 AppKit 0x00007fff8debe1b4 -[NSTextField textShouldEndEditing:] + 374
17 AppKit 0x00007fff8de62e5d -[NSTextView(NSSharing) resignFirstResponder] + 493
18 AppKit 0x00007fff8dcd16ec -[NSWindow makeFirstResponder:] + 446
19 AppKit 0x00007fff8df6e896 -[NSTextView(NSPrivate) _giveUpFirstResponder:] + 246
20 AppKit 0x00007fff8dfea912 -[NSTextView(NSKeyBindingCommands) insertNewline:] + 239
21 AppKit 0x00007fff8deb7001 -[NSTextView doCommandBySelector:] + 195
22 AppKit 0x00007fff8deb6f11 -[NSTextInputContext(NSInputContext_WithCompletion) doCommandBySelector:completionHandler:] + 118
23 AppKit 0x00007fff8de9cd33 -[NSKeyBindingManager(NSKeyBindingManager_MultiClients) interpretEventAsCommand:forClient:] + 1899
24 AppKit 0x00007fff8e463292 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke972 + 335
25 AppKit 0x00007fff8de9ed0f -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] + 76
26 AppKit 0x00007fff8deb6e13 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke_3 + 95
27 AppKit 0x00007fff8deaffe8 -[NSTextInputContext tryHandleEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 101
28 AppKit 0x00007fff8e463094 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke960 + 321
29 HIToolbox 0x00007fff94427d4f __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_5 + 70
30 HIToolbox 0x00007fff94426c45 ___ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec_block_invoke + 108
31 AppKit 0x00007fff8de9f716 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke174 + 2387
32 AppKit 0x00007fff8de9ed0f -[NSTextInputContext(NSInputContext_WithCompletion) hasMarkedTextWithCompletionHandler:] + 76
33 AppKit 0x00007fff8de9ecb0 __55-[NSTextInputContext handleTSMEvent:completionHandler:]_block_invoke_2 + 95
34 AppKit 0x00007fff8de9ec28 -[NSTextInputContext tryHandleTSMEvent_HasMarkedText_withDispatchCondition:dispatchWork:continuation:] + 101
35 AppKit 0x00007fff8de9e8e5 -[NSTextInputContext handleTSMEvent:completionHandler:] + 3122
36 AppKit 0x00007fff8de9dc3e _NSTSMEventHandler + 324
37 HIToolbox 0x00007fff943c0b6c _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1260
38 HIToolbox 0x00007fff943bffae _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 386
39 HIToolbox 0x00007fff943bfe22 SendEventToEventTargetWithOptions + 43
40 HIToolbox 0x00007fff9442426c SendTSMEvent_WithCompletionHandler + 417
41 HIToolbox 0x00007fff9442476c __SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler_block_invoke + 400
42 HIToolbox 0x00007fff944245a6 __SendFilterTextEvent_WithCompletionHandler_block_invoke + 189
43 HIToolbox 0x00007fff944242c0 SendTSMEvent_WithCompletionHandler + 501
44 HIToolbox 0x00007fff9442408f SendFilterTextEvent_WithCompletionHandler + 236
45 HIToolbox 0x00007fff94423d51 SendUnicodeTextAEToUnicodeDoc_WithCompletionHandler + 295
46 HIToolbox 0x00007fff94423ae9 __utDeliverTSMEvent_WithCompletionHandler_block_invoke_2 + 296
47 HIToolbox 0x00007fff94423988 __utDeliverTSMEvent_WithCompletionHandler_block_invoke + 437
48 HIToolbox 0x00007fff944237cd TSMKeyEvent_WithCompletionHandler + 701
49 HIToolbox 0x00007fff944234d0 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_4 + 251
50 HIToolbox 0x00007fff94423386 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_3 + 330
51 HIToolbox 0x00007fff94423112 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke_2 + 259
52 HIToolbox 0x00007fff94422f25 __TSMProcessRawKeyEventWithOptionsAndCompletionHandler_block_invoke + 251
53 HIToolbox 0x00007fff9440776f TSMProcessRawKeyEventWithOptionsAndCompletionHandler + 3068
54 AppKit 0x00007fff8e462ea6 __61-[NSTextInputContext _handleEvent:options:completionHandler:]_block_invoke949 + 131
55 AppKit 0x00007fff8de9c462 -[NSTextInputContext tryTSMProcessRawKeyEvent:dispatchCondition:setupForDispatch:furtherCondition:dispatchWork:continuation:] + 127
56 AppKit 0x00007fff8de9c195 -[NSTextInputContext _handleEvent:options:completionHandler:] + 1266
57 AppKit 0x00007fff8de9bc5e -[NSTextInputContext handleEvent:] + 109
58 AppKit 0x00007fff8de9bb64 -[NSView interpretKeyEvents:] + 207
59 AppKit 0x00007fff8de9b97a -[NSTextView keyDown:] + 695
60 AppKit 0x00007fff8e38b11b -[NSWindow _reallySendEvent:isDelayedEvent:] + 5452
61 AppKit 0x00007fff8dd1cd76 -[NSWindow sendEvent:] + 470
62 AppKit 0x00007fff8dd199b1 -[NSApplication sendEvent:] + 4199
63 AppKit 0x00007fff8dc42c68 -[NSApplication run] + 711
64 AppKit 0x00007fff8dbbf354 NSApplicationMain + 1832
65 RaiseMan 0x00000001000063ad main + 109
66 libdyld.dylib 0x00007fff92dc65c9 start + 1
)
Just found out… I declared the validateRaise method outside the Employee class brackets…