Jorge Vega Sánchez
Jorge Vega Sánchez

Reputation: 7590

NSCFString leaking when handling key events

I am trying to capture key presses with this code. My problem is that 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:]

Upvotes: 3

Views: 325

Answers (1)

helioz
helioz

Reputation: 910

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.

Upvotes: 1

Related Questions