0
通過Aaron Hillegass的書Cocoa Programming for Mac OS X
(第三版),我現在在第9章,在Adding Undo to RaiseMan
的末尾。 Hillegass告訴你添加兩種方法到你的班級MyDocument
,然後構建應用程序以查看撤消/重做是否已添加並正在工作。NSUndoManager處於無效狀態
但是,它不工作(爲什麼我會在這裏?)。它說:
2012-11-27 19:55:16.231 RaiseMan[293:a0f] HIToolbox: ignoring exception 'undo: NSUndoManager 0x100188a30 is in invalid state, undo was called with too many nested undo groups' that raised inside Carbon event dispatch
(
0 CoreFoundation 0x00007fff88c26784 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x00007fff858ddf03 objc_exception_throw + 45
2 CoreFoundation 0x00007fff88c265a7 +[NSException raise:format:arguments:] + 103
3 CoreFoundation 0x00007fff88c26534 +[NSException raise:format:] + 148
4 Foundation 0x00007fff86fd0e17 -[NSUndoManager undo] + 239
5 AppKit 0x00007fff8976eeda -[NSApplication sendAction:to:from:] + 95
6 AppKit 0x00007fff8979346a -[NSMenuItem _corePerformAction] + 365
7 AppKit 0x00007fff897931d4 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 121
8 AppKit 0x00007fff89a18cf4 -[NSMenu _internalPerformActionForItemAtIndex:] + 35
9 AppKit 0x00007fff898ca9e9 -[NSCarbonMenuImpl _carbonCommandProcessEvent:handlerCallRef:] + 136
10 AppKit 0x00007fff8977599c NSSLMMenuEventHandler + 321
11 HIToolbox 0x00007fff83d937f7 _ZL23DispatchEventToHandlersP14EventTargetRecP14OpaqueEventRefP14HandlerCallRec + 1002
12 HIToolbox 0x00007fff83d92d46 _ZL30SendEventToEventTargetInternalP14OpaqueEventRefP20OpaqueEventTargetRefP14HandlerCallRec + 395
13 HIToolbox 0x00007fff83db0a81 SendEventToEventTarget + 45
14 HIToolbox 0x00007fff83ddfc35 _ZL18SendHICommandEventjPK9HICommandjjhPKvP20OpaqueEventTargetRefS5_PP14OpaqueEventRef + 387
15 HIToolbox 0x00007fff83e0ca0a SendMenuCommandWithContextAndModifiers + 56
16 HIToolbox 0x00007fff83e0c9c2 SendMenuItemSelectedEvent + 101
17 HIToolbox 0x00007fff83e0c8d2 _ZL19FinishMenuSelectionP13SelectionDataP10MenuResultS2_ + 150
18 HIToolbox 0x00007fff83dedc27 _ZL14MenuSelectCoreP8MenuData5PointdjPP13OpaqueMenuRefPt + 467
19 HIToolbox 0x00007fff83ded37c _HandleMenuSelection2 + 453
20 AppKit 0x00007fff89646851 _NSHandleCarbonMenuEvent + 236
21 AppKit 0x00007fff8961a362 _DPSNextEvent + 1908
22 AppKit 0x00007fff89619801 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 155
23 AppKit 0x00007fff895df68f -[NSApplication run] + 395
24 AppKit 0x00007fff895d83b0 NSApplicationMain + 364
25 RaiseMan 0x000000010000160a main + 33
26 RaiseMan 0x0000000100001218 start + 52
27 ??? 0x0000000000000001 0x0 + 1
)
在控制檯,當我點擊撤消或按cmd + z。
我在網上找到了解決方案,但都是關於'UndoGroups'或類似的東西。
我知道例外是關於nested undo groups
,但我不使用它們(AFAIK),我甚至不知道它們是什麼。
我不知道我應該給什麼其他的信息,所以請在代碼片段等