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

Is there a better way to structure post methods in Class Based Views -

Qt QGraphicsScene is not accessable from QGraphicsView (on Qt 5.6.1) -

Python Tornado package error when running server -