应用程序退出崩溃

时间:2013-12-16 10:48:59

标签: objective-c cocoa nsapplication nsapplication-delegate

任何人都可以帮我解决这个崩溃问题。当应用程序退出时,会发生这种情况,但并非总是如此。

Application Specific Information:
objc_msgSend() selector name: respondsToSelector:
Performing @selector(terminate:) from sender NSMenuItem 0x34cfd0

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x979414cc objc_msgSend + 44
1   com.apple.MyApp                 0x00026d9f -[MyAppController applicationShouldTerminate:] + 398
2   com.apple.AppKit                0x91086dc2 -[NSApplication _docController:shouldTerminate:] + 83
3   com.apple.AppKit                0x91086cb4 __91-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke + 140
4   com.apple.AppKit                0x910869c0 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1304
5   com.apple.AppKit                0x9108646b -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 266
6   com.apple.AppKit                0x91086103 -[NSApplication _shouldTerminate] + 760
7   com.apple.AppKit                0x90f88008 -[NSApplication terminate:] + 1139
8   libobjc.A.dylib                 0x97957283 -[NSObject performSelector:withObject:] + 70
9   com.apple.AppKit                0x90f2fd75 -[NSApplication sendAction:to:from:] + 438
10  com.apple.AppKit                0x90f4c315 -[NSMenuItem _corePerformAction] + 486
11  com.apple.AppKit                0x90f4c01a -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 163
12  com.apple.AppKit                0x90f4b6c9 -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 79
13  com.apple.AppKit                0x90f4b675 -[NSMenu _performActionWithHighlightingForItemAtIndex:] + 48
14  com.apple.AppKit                0x90f4b022 -[NSMenu performKeyEquivalent:] + 294
15  com.apple.AppKit                0x90f47735 -[NSApplication _handleKeyEquivalent:] + 938
16  com.apple.AppKit                0x90eb0cbe -[NSApplication sendEvent:] + 3911
17  com.apple.AppKit                0x90cf56cc -[NSApplication run] + 823
18  com.apple.AppKit                0x90cde558 NSApplicationMain + 1165
19  com.apple.MyApp                 0x00111c9a main + 728
20  com.apple.MyApp                 0x00002401 start + 53

有些时候,我在退出时崩溃时会收到以下崩溃日志,但这并不总是如此。

objc_msgSend() selector name: respondsToSelector:
objc[33814]: garbage collection is OFF

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x99546d47 objc_msgSend + 23
1   com.apple.MyApp                 0x0001c574 -[MyAppController applicationShouldTerminate:] + 390
2   com.apple.AppKit                0x915f6701 -[NSApplication _docController:shouldTerminate:] + 83
3   com.apple.AppKit                0x917240ff __-[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:]_block_invoke_1 + 228
4   com.apple.AppKit                0x91730f86 -[NSDocumentController(NSInternal) _closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 1693
5   com.apple.AppKit                0x91729ec6 -[NSDocumentController(NSInternal) __closeAllDocumentsWithDelegate:shouldTerminateSelector:] + 310
6   com.apple.AppKit                0x915fdb15 -[NSApplication _shouldTerminate] + 889
7   com.apple.AppKit                0x91334332 -[NSApplication terminate:] + 1219
8   com.apple.CoreFoundation        0x90c1dd11 -[NSObject performSelector:withObject:] + 65
9   com.apple.AppKit                0x914371ff -[NSApplication sendAction:to:from:] + 232
10  com.apple.AppKit                0x9152ad8b -[NSMenuItem _corePerformAction] + 536
11  com.apple.AppKit                0x9152aa08 -[NSCarbonMenuImpl performActionWithHighlightingForItemAtIndex:] + 171
12  com.apple.AppKit                0x9152a091 -[NSMenu _performActionWithHighlightingForItemAtIndex:sendAccessibilityNotification:] + 79
13  com.apple.AppKit                0x9152a03d -[NSMenu _performActionWithHighlightingForItemAtIndex:] + 48
14  com.apple.AppKit                0x914a3923 -[NSMenu performKeyEquivalent:] + 306
15  com.apple.AppKit                0x914a2392 -[NSApplication _handleKeyEquivalent:] + 594
16  com.apple.AppKit                0x91397cef -[NSApplication sendEvent:] + 5772
17  com.apple.AppKit                0x91329459 -[NSApplication run] + 1007
18  com.apple.AppKit                0x915babf1 NSApplicationMain + 1054
19  com.apple.MyApp                 0x0010094b main + 216
20  com.apple.MyApp                 0x0000264d start + 53

1 个答案:

答案 0 :(得分:1)

当然,首先要看你的-[MyAppController applicationShouldTerminate:],假设你已经实现了这一点。您可能指的是已经发布的对象(这是ARC吗?这种错误的最常见原因是无法使用ARC。)

如果您尚未实施applicationShouldTerminate:,则可能是您过度发布了应用委托自身。 NSZombies可以帮助诊断。