objective c - Reading Multiple Dragged-n-Dropped Files -


i have small window inside main xib (mainmenu.xib) nsimageview control os x application. view control has nsimageview subclass supposed accept files user brings (drag n drop). since have no experience in developing mac application objective-c, i've searched around, checking out sample projects apple, , got idea. well, make story short, i've copied code posted here. works. great... following concise version.

- (nsdragoperation)draggingentered:(id <nsdragginginfo>)sender{     return nsdragoperationcopy; }  - (nsdragoperation)draggingupdated:(id <nsdragginginfo>)sender{ }  - (void)draggingexited:(id <nsdragginginfo>)sender{ }  - (bool)preparefordragoperation:(id <nsdragginginfo>)sender{     return yes;  }  - (bool)performdragoperation:(id<nsdragginginfo>)sender {     nspasteboard *pboard = [sender draggingpasteboard];     if ([[pboard types] containsobject:nsurlpboardtype]) {         nsurl *fileurl = [nsurl urlfrompasteboard:pboard];         nslog(@"path: %@", [self convertpath:fileurl]); // <== that's need     }     return yes; }  - (nsstring *)convertpath:(nsurl *)url {     return url.path; } 

for now, drop box gets file paths 1 @ time regardless of number of files user drags , drops onto drop box. know how application read multiple files user brings.

thank you,

change performdragoperation: method this:

- (bool)performdragoperation:(id<nsdragginginfo>)sender {     nspasteboard *pboard = [sender draggingpasteboard];     if ([[pboard types] containsobject:nsurlpboardtype]) {         nsarray *urls = [pboard readobjectsforclasses:@[[nsurl class]] options:nil];         nslog(@"urls are: %@", urls);      }     return yes; } 

Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -