@@ -11,14 +11,7 @@ @implementation MRDragView
1111
1212- (void )registerDragTypes
1313{
14- if (@available (macOS 10.13 , *)) {
15- [self registerForDraggedTypes: [NSArray arrayWithObjects: NSPasteboardTypeFileURL , nil ]];
16- } else if (@available (macOS 10.0 , *)){
17- #pragma clang diagnostic push
18- #pragma clang diagnostic ignored"-Wdeprecated-declarations"
19- [self registerForDraggedTypes: [NSArray arrayWithObjects: NSFilenamesPboardType , nil ]];
20- #pragma clang diagnostic pop
21- }
14+ [self registerForDraggedTypes: [NSArray arrayWithObjects: NSPasteboardTypeFileURL , nil ]];
2215}
2316
2417- (id )initWithFrame : (NSRect )frameRect
@@ -46,25 +39,19 @@ - (NSArray *)draggedFileList:(id<NSDraggingInfo> _Nonnull)sender
4639{
4740 NSPasteboard *pboard = [sender draggingPasteboard ];
4841 NSArray *list = nil ;
49- if (@available (macOS 10.13 , *)) {
50- if ([[pboard types ] containsObject: NSPasteboardTypeFileURL ]) {
51- list = [pboard readObjectsForClasses: @[[NSURL class ]] options: nil ];
52- }
53- } else {
54- #pragma clang diagnostic push
55- #pragma clang diagnostic ignored"-Wdeprecated-declarations"
56- if ([[pboard types ] containsObject: NSFilenamesPboardType ]) {
57- list = [pboard propertyListForType: NSFilenamesPboardType ];
58- }
59- #pragma clang diagnostic pop
42+ if ([[pboard types ] containsObject: NSPasteboardTypeFileURL ]) {
43+ list = [pboard readObjectsForClasses: @[[NSURL class ]] options: nil ];
6044 }
6145
62- NSMutableArray *result = [NSMutableArray arrayWithArray: list];
46+ NSMutableArray < NSURL *> *result = [NSMutableArray arrayWithArray: list];
6347 for (int i = 0 ; i < [result count ]; i ++) {
64- id obj = result[i];
48+ NSURL * obj = result[i];
6549 if ([obj isKindOfClass: [NSString class ]]) {
6650 obj = [NSURL fileURLWithPath: (NSString *)obj];
6751 result[i] = obj;
52+ } else {
53+ // convert file:///.file/id=6571367.2701401 to normal path
54+ result[i] = [NSURL fileURLWithPath: [obj path ]];;
6855 }
6956 }
7057 return [result copy ];
0 commit comments