ios - Accessing a CollectionViewCells data when selected -


i have uicollectionviewcell who's data want access when tapped. data used in view controller... instance, when tap on friend, next viewcontroller presented page tapped friends data.

here didselectitemat indexpath

override func collectionview(_ collectionview: uicollectionview, didselectitemat indexpath: indexpath) {      let layout = uicollectionviewflowlayout()     let vc = joingroupchatcontroller(collectionviewlayout: layout)     vc.selectedindex = indexpath      let livecell = livecell()     vc.descriptionlabel = livecell.descriptionlabel.text      present(vc, animated: true, completion: nil) } 

in essence want need indexpaths specific description label not default livecell label text.

i know need use indexpath somewhere not sure / how. suggestions?

replace

let livecell = livecell() 

with

let livecell = collectionview.cellforitem(at: indexpath) as! livecell 

Comments

Popular posts from this blog

angular - DownloadURL return null in below code -

meteor - inserting data to database gives error "insert failed: Method '/texts/insert' not found" -