Skip to content

Instantly share code, notes, and snippets.

View stevebartholomew's full-sized avatar

Stephen Bartholomew stevebartholomew

View GitHub Profile
[
{
"name": "Stephen Bartholomew",
"email": "[email protected]",
"age": 34,
"languages": ["Ruby", "Javascript"]
},
{
"name": "Tim Peat",
"email": "[email protected]",
func tableView(tableView: NSTableView, validateDrop info: NSDraggingInfo, proposedRow row: Int, proposedDropOperation dropOperation: NSTableViewDropOperation) -> NSDragOperation {
tableView.setDropRow(row, dropOperation: NSTableViewDropOperation.Above)
return NSDragOperation.Move
}
override func viewDidLoad() {
// …
tableView.registerForDraggedTypes([MyRowType, NSFilenamesPboardType])
//…
}
let MyRowType = “MyRowType"
func tableView(tableView: NSTableView, writeRowsWithIndexes: NSIndexSet, toPasteboard: NSPasteboard) -> Bool {
var data = NSKeyedArchiver.archivedDataWithRootObject([writeRowsWithIndexes])
toPasteboard.declareTypes([MyRowType], owner:self)
toPasteboard.setData(data, forType:MyRowType)
return true
func tableView(tableView: NSTableView, acceptDrop info: NSDraggingInfo, row: Int, dropOperation: NSTableViewDropOperation) -> Bool {
var pasteboard = info.draggingPasteboard()
var rowData = pasteboard.dataForType(MyRowType)
if(rowData != nil) {
var dataArray = NSKeyedUnarchiver.unarchiveObjectWithData(rowData!) as! Array<NSIndexSet>,