I need some help understanding what's causing a leak in my app. App uses ARC. I have an NSView on a window functioning as a drop zone for files. When you drag a file onto the window I pick up the path and the file name to use in other aspects of the application.
When I run the application through Instruments, there is a memory leak as soon as I launch the application. Here's a link to a snapshot of what is returned in Instruments:
http://f-video.s3.amazonaws.com/leak.jpg
Below is the Drag and Drop code for my custom class (dropZone).
I need a lesson on this. I don't understand how to read the data returned in Instruments to make the correction.
Thanks for the help.
@implementation dropZone
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
// Initialization code here.
[self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];
}
return self;
}
- (void)drawRect:(NSRect)dirtyRect {
/*NSRect bounds = [self bounds];
[[NSColor grayColor] set];
[NSBezierPath fillRect:bounds];*/
}
- (NSDragOperation)draggingEntered:(id )sender {
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
sourceDragMask = [sender draggingSourceOperationMask];
pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
if (sourceDragMask & NSDragOperationLink) {
return NSDragOperationLink;
} else if (sourceDragMask & NSDragOperationCopy) {
return NSDragOperationCopy;
}
}
return NSDragOperationNone;
}
- (BOOL)performDragOperation:(id )sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
if ( [[pboard types] containsObject:NSFilenamesPboardType] ) {
NSArray *files = [pboard propertyListForType:NSFilenamesPboardType];
// Perform operation using the list of files
NSLog(@"Dragged files");
int i;
for (i = 0; i < [files count]; i++) {
NSLog(@"%@",[files objectAtIndex:i]);
NSString * new = [files objectAtIndex:i];
[[NSApp delegate] updateText:new];
}
}
return YES;
}
@end