title: How to access values in one class from another? Swift 4
body: <p>I have an app where when a user taps a <code>cell</code> from a <code>TableView</code> representing a group of images, he is taken to another tableView where all the images within that group should be shown. However I am unsure of how to do this. </p>
  
  <p>I have currently have extracted at the beginning the info necessary to make a reference and get all the data, which is in an array of objects. However how can I access these values from another class?</p>
  
  <p>DataModel: </p>
  
  <pre><code>struct UserImage {
      var userID: String
      var image: UIImage
      var postNum: String
  }
  </code></pre>
  
  <p>I am creating an array of this as shown bellow, in a <code>P1TableVC</code>:</p>
  
  <pre><code>let arrayOfUserImageData = [UserImage]()
  </code></pre>
  
  <p>The function which retrieves and store the data looks as follows:</p>
  
  <pre><code>func fetchAllUserFristImage() {
  print("Description: calling of fetchAllUserFristImage()")
  Database.database().reference().child("Posts").observe(.childAdded, with: {(snapshot) in
  
      if snapshot.value as? [String: AnyObject] != nil {
          let user = snapshot.key
          print("Description: calling of snapshot.value is not nil ")
  
          self.databaseRef = Database.database().reference()
  
          let usersPostRef2 = self.databaseRef.child("Posts").child(user)
  
          usersPostRef2.observe(.value, with: {(postXSnapshots) in
  
              if let postDictionary2 = postXSnapshots.value as? [String:AnyObject] {
  
                  for (p) in postDictionary2 {
  
                      if let posts = p.value as? [String:AnyObject] {
                          print("Description: posts has value of:  \(posts)")
  
                          //to get back to where i was delete the below for i
                          for (i) in posts {
  
                              if let imageUrlString = i.value as? [String:AnyObject], let postUrl = imageUrlString["image1"] as? String {
                                  print("Description: inside the if let imageUrlString = i.value ")
  
                                  self.feedArray.append(Post(fetchedImageURL: postUrl))
                                  if let imageUrl = URL(string: postUrl), let imageDataL = try? Data(contentsOf: imageUrl), let image = UIImage(data: imageDataL) {
                                      print("Description: inside the if let imageUrl = URL(string: postUrl)")
                                      print("Description: img url's of posts: \(imageUrl)")
                                      self.tableData.append(UserImage(userID: user, image: image, postNum: p.key))
                                      self.tableView.reloadData()
                                  } else {print("this user had no posts, was nil")}
                              }
                          }
                      }
                  }
              }
          })
          //below shud stay same
          DispatchQueue.main.async {
              self.tableView.reloadData()
          }
      }
  })
  }
  </code></pre>