DragDropImageView 1.0.1

DragDropImageView 1.0.1

LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Nov 2015

Maintained by Léo Derbois.



To run the example project, clone the repo, and run pod install from the Example directory first.


SDK 10.7 (Mavericks) minimum


How To

DragDropImageView is a custom NSImageView which can accept Drag and Drop Operation. To use it just make inherit an NSImageView on your nib and implement DragDropImageViewDelegate protocol in your controller.

Delegate Protocol Exemple

Implement DragDropImageViewDelegate methods like this in your controller.

-(NSImage *)dragDropImageView:(DragDropImageView *)dragDropImageView imageForStatus:(DragDropStatus)status{
    NSImage * image = s_empty;

    id dataToTest = nil;
    if(dragDropImageView == _dragDropSingle){
        dataToTest = self.pathSingleFile;
    } else {
        dataToTest = self.pathMultiFile;
    if(status == DragDropValidType){
        image = s_validType;
    } else if(status==DragDropInvalidType) {
        image = s_invalidType;
    } else if(dataToTest){
        image =s_accepted;
    return image;

-(BOOL)dragDropImageView:(DragDropImageView *)dragDropImageView areValidFiles:(NSArray *)files{
    __block BOOL valid = NO;
    [files enumerateObjectsUsingBlock:^(id object, NSUInteger idx, BOOL *stop) {
        CFStringRef fileExtension = (__bridge CFStringRef)[object pathExtension];
        CFStringRef fileUTI       = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, NULL);

        valid = UTTypeConformsTo(fileUTI, kUTTypeAudio);
        *stop = !valid;

    return valid;
-(void)dragDropImageView:(DragDropImageView *)dragDropImageView provideFiles:(NSArray *)files{
    if(dragDropImageView == _dragDropSingle){
        self.pathSingleFile = files[0];
    } else {
        self.pathMultiFile = files;


Léo Derbois, [email protected], www.leoderbois.com


DragDropImageView is available under the MIT license. See the LICENSE file for more info.