Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions DragDropDemo/DragDropImageView.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,35 @@ @implementation DragDropImageView

NSString *kPrivateDragUTI = @"com.yourcompany.cocoadraganddrop";

- (id)initWithCoder:(NSCoder *)coder

- (instancetype)initWithFrame:(NSRect)frame
{
/*------------------------------------------------------
Init method called for Interface Builder objects
--------------------------------------------------------*/
self=[super initWithCoder:coder];
if ( self ) {
//register for all the image types we can display
[self registerForDraggedTypes:[NSImage imagePasteboardTypes]];
self.allowDrag = YES;
self.allowDrop = YES;
self = [super initWithFrame:frame];
if (self)
{
[self setup];
}
return self;
}

- (instancetype)initWithCoder:(NSCoder *)coder
{
self = [super initWithCoder:coder];
if (self) {
[self setup];
}
return self;
}

- (void)setup
{
[self registerForDraggedTypes:[NSImage imagePasteboardTypes]];
self.allowDrag = YES;
self.allowDrop = YES;
}



#pragma mark - Destination Operations

- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
Expand Down