问题描述
由于某种原因,在控制台中我得到了
For some reason, in the Console I'm getting
:kCGErrorFailure:设置一个断点@ CGErrorBreakpoint()到在记录错误时捕获错误.
: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint() to catch errors as they are logged.
使用(我认为)此代码...
with (I think) this code ...
- (void)applicationDidResignActive:(NSNotification*)aNotification
{
statusItem = [[NSStatusBar systemStatusBar]
statusItemWithLength:NSVariableStatusItemLength];
[statusItem setHighlightMode:YES];
[statusItem setEnabled:YES];
//Set menubar item's tooltip
[statusItem setToolTip:@"Nucleus"];
[statusItem setMenu:theMenu];
//Set the menubar item's title
[statusItem setTitle:[NSString stringWithString:@"N"]];
[statusItem retain];
}
- (void)applicationDidBecomeActive:(NSNotification*)aNotification
{
[[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
}
我相信这是堆栈跟踪(?):
I believe this is the stack trace (?) :
0x00007fff8667349b< +0000>推送%rbp
0x00007fff8667349c< +0001> mov%rsp,%rbp
0x00007fff8667349f< +0004> mov%edi,%eax
0x00007fff866734a1< +0006>离开q
0x00007fff866734a2< +0007> retq
0x00007fff866734a3< +0008> nop
0x00007fff8667349b <+0000> push %rbp
0x00007fff8667349c <+0001> mov %rsp,%rbp
0x00007fff8667349f <+0004> mov %edi,%eax
0x00007fff866734a1 <+0006> leaveq
0x00007fff866734a2 <+0007> retq
0x00007fff866734a3 <+0008> nop
为什么?我该如何解决?
Why? How can I fix this?
我在Mac上使用可可粉吗?
I'm using Cocoa on Mac?
推荐答案
我不确定是什么导致了该错误,但是我确实注意到,每次应用程序停用时,您都会泄漏 statusItem
.将 [statusItem release]
从statusBar中删除后,可能会有所帮助(它肯定会解决您的泄漏问题).
I'm not sure what's causing the error, but I do notice that you're leaking statusItem
every time the application deactivates. Perhaps adding a [statusItem release]
after removing it from the statusBar will help (it will definitely fix your leak).
这篇关于NSStatusItem"kCG ..."失误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!