diff --git a/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate b/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate index d06c5e1..bc3346f 100644 Binary files a/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate and b/GHFollowers.xcodeproj/project.xcworkspace/xcuserdata/vasilis.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/GHFollowers/Screens/FavoriteListVC.swift b/GHFollowers/Screens/FavoriteListVC.swift index 981c2c5..dd78927 100644 --- a/GHFollowers/Screens/FavoriteListVC.swift +++ b/GHFollowers/Screens/FavoriteListVC.swift @@ -96,9 +96,7 @@ extension FavoriteListVC: UITableViewDelegate, UITableViewDataSource { // get the selected row of the tableView func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let favorite = favorites[indexPath.row] - let destinationVC = FollowerListVC() - destinationVC.username = favorite.login - destinationVC.title = favorite.login + let destinationVC = FollowerListVC(username: favorite.login) navigationController?.pushViewController(destinationVC, animated: true) } diff --git a/GHFollowers/Screens/FollowerListVC.swift b/GHFollowers/Screens/FollowerListVC.swift index 6926557..5a56192 100644 --- a/GHFollowers/Screens/FollowerListVC.swift +++ b/GHFollowers/Screens/FollowerListVC.swift @@ -39,6 +39,19 @@ class FollowerListVC: UIViewController { var dataSource: UICollectionViewDiffableDataSource! + // username is the inout text passed from the SearchVC + init (username: String) { + super.init(nibName: nil, bundle: nil) + self.username = username + title = username + } + + required init?(coder: NSCoder) { + fatalError("init(coder:) has not been implemented") + } + + + override func viewDidLoad() { super.viewDidLoad() diff --git a/GHFollowers/Screens/SearchVC.swift b/GHFollowers/Screens/SearchVC.swift index 75c72c8..e384c65 100644 --- a/GHFollowers/Screens/SearchVC.swift +++ b/GHFollowers/Screens/SearchVC.swift @@ -72,12 +72,8 @@ class SearchVC: UIViewController { // dismiss keyboard when changing view userNameTextFiled.resignFirstResponder() - let followerListVC = FollowerListVC() - // pass the value of the input to the FollowersVC View - followerListVC.username = userNameTextFiled.text - // same for the navigation title - followerListVC.title = userNameTextFiled.text - // finally handle the navigation + let followerListVC = FollowerListVC(username: userNameTextFiled.text!) + // handle the navigation navigationController?.pushViewController(followerListVC, animated: true) }