2017-02-27 20 views
0

在這個例程中 - tableView validateDrop,我需要了解返回的項目。返回項目數組似乎是文件ID?查找器URL解釋

func tableView(tableView: NSTableView, validateDrop info: NSDraggingInfo, 
proposedRow row: Int, proposedDropOperation dropOperation: NSTableViewDropOperation) -> NSDragOperation { 
    print("validate drop \(dropOperation)") 
    if dropOperation == .Above { 
     //get the file URLs from the pasteboard 
     let pasteboard = info.draggingPasteboard() 

     //list the file type UTIs we want to accept 
     let options = [NSPasteboardURLReadingFileURLsOnlyKey : true, 
         NSPasteboardURLReadingContentsConformToTypesKey : [kUTTypeMovie as String]] 
     let items = pasteboard.readObjectsForClasses([NSURL.classForCoder()], 
                 options: options) 
     if items!.count > 0 { 
      for item in items! { 
       print("item -> \(item)") 
      } 

      print("validate Above -> .Copy") 
      return .Copy; 

     } else { 

      print("validate Above -> .Move") 
      return .Move 

     } 
    } 
    print("validate other -> .None") 
    return .None 
} 

,輸出:

item -> file:///.file/id=6571367.34508463 

在某些時候,我需要這個翻譯成什麼,我可以使用 - 典型的文件:// URL格式。

回答

0

po item.filePathURL 
▿ Optional<NSURL> 
    - Some : file:///Users/slashlos/Movies/Flight%20to%20Mars.m4v 

,我很可能對用戶觀看

反轉義