Skip to content

Instantly share code, notes, and snippets.

@limabeans
Created November 13, 2016 02:32
Show Gist options
  • Save limabeans/258ba3adabbd1d9f43903f6a6ce2d36a to your computer and use it in GitHub Desktop.
Save limabeans/258ba3adabbd1d9f43903f6a6ce2d36a to your computer and use it in GitHub Desktop.
UICollectionViewCell and segue
/*
There is a button in each UICVCell, and we want to pass data based on a specific cell when we segue.
*/
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destController = segue.destination as! CommentController
if let selectedFeedCell = (sender! as AnyObject).superview!?.superview as? FeedCell {
let indexPath = self.collectionView!.indexPath(for: selectedFeedCell)!
let row = indexPath.row
destController.feedItemInd = row
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment