title: Pass data from a Parent ViewController to Child VC without Storyboards - Swift 5
body: <p>I couldn't find a way to pass the data to the Child VC once i get the data through a UITextField from the Github API</p>
  
  <pre><code>protocol GithubManagerDelegate {
      func didUpdateGithub(_ githubManager: GithubManager, github: GithubModel)
      func didFailWithError(error: Error)
  }
  
  struct GithubManager {
      let profileUrl = "https://api.github.com/users"
      let clientId = // deleted this
      let secretId = // deleted this
  
      var delegate: GithubManagerDelegate?
  
      func fetchProfile(profileName: String) {
          let urlString = "\(profileUrl)/\(profileName)?client_id=\(clientId)&amp;client_secret=\(secretId)"
  
          performRequest(with: urlString)
      }
  
  
      func performRequest(with urlString: String) {
          if let url = URL(string: urlString) {
              let session = URLSession(configuration: .default)
              let task = session.dataTask(with: url) { (data, response, error) in
                  if error != nil {
                      self.delegate?.didFailWithError(error: error!)
                      return
                  }
  
                  if let safeData = data {
                      if let github = self.parseJSON(safeData) {
                          self.delegate?.didUpdateGithub(self, github: github)
                          print(github)
                      }
                  }
              }
              task.resume()
          }
  
      }
  
      func parseJSON(_ githubData: Data) -&gt; GithubModel? {
          let decoder = JSONDecoder()
  
          do {
              let decodeData = try decoder.decode(GithubData.self, from: githubData)
              let name = decodeData.name ?? "The user does not have a name"
              let login = decodeData.login ?? "No username by this name." // TODO: Change to give a alert
              let avatarUrl = decodeData.avatar_url
              let blog = decodeData.blog ?? "No Blog"
              let bio = decodeData.bio ?? "No Bio"
              let location = decodeData.location ?? "No location"
              let followers = decodeData.followers
              let following = decodeData.following
  
  
              let github = GithubModel(githubName: login, githubUser: name, githubAvatar: avatarUrl, githubBio: bio, githubLocation: location, githubBlog: blog, githubFollowers: followers, githubFollowing: following)
  
              return github
  
          } catch {
              delegate?.didFailWithError(error: error)
              return nil
          }
      }
  }
  </code></pre>
  
  <p>In the Parent VC in the textFieldDidEndEditing I take the input text and use that to fetch the information from the GithubAPI</p>
  
  <pre><code>if let username = searchTextField.text {
              DispatchQueue.main.async {
                  self.githubManager.fetchProfile(profileName: username)
              }
          }
  </code></pre>
  
  <p>Then in my Child VC I use the GithubManagerDelegate, where I use DispatchQueue where, to populate the labels with the information. But the information is empty, because I can't pass the to the child once the data is recieved.</p>
  
  <pre><code>func didUpdateGithub(_ githubManager: GithubManager, github: GithubModel) {
          DispatchQueue.main.async {
              self.usernameLabel.text = github.githubName
          }
      }
  </code></pre>
  
  <p>The way I go from the ParentVC to ChildVC:</p>
  
  <p><strong>navigationController?.pushViewController(profileVC, animated: true)</strong></p>
  
  <p>Hopefully I made myself clear what the problem is...</p>