Skip to content

Instantly share code, notes, and snippets.

@danielwestendorf
Created May 27, 2011 20:00
Show Gist options
  • Save danielwestendorf/996043 to your computer and use it in GitHub Desktop.
Save danielwestendorf/996043 to your computer and use it in GitHub Desktop.
def tableView(aView, acceptDrop:info, row:droppedRow, dropOperation:op)
pboard = info.draggingPasteboard
row_data_array = YAML.load(pboard.stringForType("MyRowDataType")) #grab the YAML from the pasteboard and convert it back to an array
row_data_array.reverse.each do |row| #You'll want to insert your rows in reverse order to maintain the indexes, thus the reverse call
#rearrange your table_data_array accordingly here. droppedRow represents index value of where the row was dropped.
end
table_view.deselectAll(nil) #Deselect everything after the drop
table_view.reloadData #redraw the table to show the updates
return true #if everything went as planned, return true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment