NSCFString leaking when handling key events
I am trying to capture key presses with this code. My problem is tha开发者_StackOverflow中文版t Instruments throws a message about a leak.
I am working without Garbage Collection.
-(void)keyDown:(NSEvent *)theEvent
{
if ([theEvent keyCode]==0)
{
NSLog(@"Break");
}
}
- (BOOL)acceptsFirstResponder
{
return YES;
}
- (BOOL)becomeFirstResponder
{
return YES;
}
- (BOOL)resignFirstResponder
{
return YES;
}
Message thrown by Instruments:
Leaked Object # Address Size Responsible Library Responsible Frame NSCFString, 0x10067e540 32 Bytes AppKit -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]
Look at Why is NSOpenPanel/NSSavePanel showing memory leak? and NSTextField leaking when handling key events
Your problem shows the same symptoms and it may also be a "False Positive".
Credit for this answer should go to Rob Keniger he has pointed me in the right direction.
精彩评论