Skip to content

Instantly share code, notes, and snippets.

@jaunesarmiento
Created November 13, 2013 18:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaunesarmiento/7454049 to your computer and use it in GitHub Desktop.
Save jaunesarmiento/7454049 to your computer and use it in GitHub Desktop.
Passing data between view controllers using segues
class MyViewController < UITableViewController
attr_accessor :datasource
# .. UITableViewController delegate methods here ..
def prepareForSegue(segue, sender: sender)
if (segue.identifier.isEqualToString("segueIdentifier"))
index_path = @datasource.indexPathForSelectedRow
destination_view_controller = segue.destinationViewController
# Given that the destination view controller has attr_accessor :datasource
destination_view_controller.datasource = @datasource[index_path.row]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment