title: Pass data from CollectionviewCell to ViewController
body: <p>when i write the function touchphoto, the post.postID is nil .I want to pass the postID to another view controller. I add the code for the profilecell and profileviewcontroller</p>
  
  <pre><code>protocol profilecellDelegate {
  func goToPhotoDetail(postid: String)}
  
  class profilecell: UICollectionViewCell {
  var delegate: profilecellDelegate?
  
  @IBOutlet weak var image: UIImageView!
  
  var post: Post? {
      didSet {
          updateView()
      }
  }
  
  func updateView() {
      if let photoUrlString = post?.photoUrl {
          let photoUrl = URL(string: photoUrlString)
          image.sd_setImage(with: photoUrl)
      }
  }
  
  @IBAction func touchphoto(_ sender: Any) {
      if let id = post?.postID {
          delegate?.goToPhotoDetail(postid: id)
      }
  }
  }
  
  
  
  //profileviewcontroller
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell {
      let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "profilecell", for: indexPath) as! profilecell
      let post = posts[indexPath.row]
      cell.post = post
      cell.delegate = self
      return cell
  }
  extension ProfileViewController: profilecellDelegate {
  func goToPhotoDetail(postid: String) {
      performSegue(withIdentifier: "Photo_ProfileSegue", sender: postid)
  }}
  </code></pre>