- Let's continue using our previous demo to add a way to share the contact information when a user clicks on it.
- Let's start by handling the selection of cells in a table view. Override the following function in UITableViewDelegate:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let contact = self.contacts[indexPath.row] self.shareContact(contact: contact) }
- Add the following function to share the content:
func shareContact(contact: Contact){ let contactInfo = "Name: (contact.firstName) (contact.lastName) nEmail: (contact.email)n Cell phone: (contact.cellPhone)" let photoImageURL = URL(string: contact.pictureURLString) let activityViewController = UIActivityViewController(activityItems: ...