Hello Guys,
I would like to know how to get the sender of the avatar i tapped on ?
Like in the below example:
extension MessagesListVC: MessageCellDelegate {
func didTapAvatar(in cell: MessageCollectionViewCell) {
print("Avatar tapped") // I would like to see the id of the sender with this avatar
}
func didTapMessage(in cell: MessageCollectionViewCell) {
print("Message tapped") // Same here
}
}
Thanks :)
Hey @gorbat-o,
I would do something like this:
func didTapAvatar(in cell: MessageCollectionViewCell) {
guard let indexPath = messagesCollectionView.indexPath(for: cell) else { return }
guard let messagesDataSource = messagesCollectionView.messagesDataSource else { return }
let message = messagesDataSource.messageForItem(at: indexPath, in: messagesCollectionView)
// here you can get the sender
let sender = message.sender
}
Oh, good job, I didn't think that way.
Thanks :)
Most helpful comment
Hey @gorbat-o,
I would do something like this: