objective c - How to Drag&Drop images from browser to Cocoa app -


i need drag images browser mac app. when dragging images img tag, works when there link between img, doesn’t work. nspasteboard receives nsurl link, not img source. drag feedback shows image, think it’s sending image data. i’ve checked propertylistfortype nspasteboard, , contains link href.

- (bool)performdragoperation:(id <nsdragginginfo>)sender {     if ([sender draggingsource] == nil){         nspasteboard *pboard = [sender draggingpasteboard];          if ([[pboard types] containsobject:nsurlpboardtype]){             nsurl* file = [nsurl urlfrompasteboard: [sender draggingpasteboard]];             //if <img> tag, file src. if <a><img></a>, it’s link href              //download image here         }     } }     

there should variety of types offered on nspasteboard. first thing whenever i’m writing pasteboard receiving code write debugging code dumps available types , values when drag happens view. pick , choose ones want.

as start, just

nslog(@“types %@“, pboard.types); 

i’ll leave exercise dump values. :)


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -