Methods “matchmakerViewControllerWasCancelled” and “matchmakerViewController” not being called inside of GKMatchmakerViewControllerDelegate

I am making a real time multiplayer game with swift, SpriteKit and most importantly GameKit, however I am fairly new to swift and swift UI.

I have initialized my 
Code Block
GKMatchmakerViewController
 with a
Code Block
 GKrequest
, and believe that I have set that particular view controller's delegate to be the view controller it is inside of. Doing this required me to conform the larger view controller to the protocol of 
Code Block
GKMatchmakerViewControllerDelegate
 which gave me the functions 
Code Block
matchmakerViewControllerWasCancelled
 and 
Code Block
matchmakerViewController:didFailWithError:
 which should be called when either I cancel out of the matchmaking controller or it crashes with an error.
My problem is that neither of these functions seem to be getting called unless I do it manually. I am not entirely sure if I have properly set the controller delegate, which I believe to be the root of the problem, however if anyone has any, more experienced, insight I would gladly appreciate it. The conforming View Controller's code is shown below. All help is appreciated!

Code Block
let request = GKMatchRequest()
class SecondScreenViewController : UIViewController, UINavigationControllerDelegate, GKMatchmakerViewControllerDelegate {
let button = UIButton()
let softRed = UIColor(red: 1, green: 61 / 255, blue: 61 / 255, alpha: 1)
let softblue = UIColor(red: 38 / 255, green: 149 / 255, blue: 1, alpha: 1)
let TestMatchMaker = GKMatchmaker()
let TestMatch = GKMatch()
var TestViewController = GKMatchmakerViewController(matchRequest: request)
override func viewDidLoad() {
super.viewDidLoad()
setupButton()
SetupRequest()
view.backgroundColor = softblue
}
func matchmakerViewControllerWasCancelled(_ viewController: GKMatchmakerViewController) {
dismiss(animated: true, completion: nil)
}
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFailWithError error: Error) {
}
func matchmakerViewController(_ viewController: GKMatchmakerViewController, didFind match: GKMatch) {
print("yess")
}
func SetupRequest() {
request.minPlayers = 2
request.maxPlayers = 2
request.inviteMessage = "test Invite"
}
func setupButton() {
button.backgroundColor = UIColor.white
button.setTitleColor(softblue, for: .normal)
button.setTitle("MatchMake", for: .normal)
button.addTarget(self, action: #selector(ButtonTapped), for: .touchUpInside)
view.addSubview(button)
setupButtonConstraints()
}
func setupButtonConstraints() {
button.translatesAutoresizingMaskIntoConstraints = false
button.leadingAnchor.constraint(equalTo: view.leadingAnchor, constant: 30).isActive = true
button.trailingAnchor.constraint(equalTo: view.trailingAnchor, constant: -30).isActive = true
button.heightAnchor.constraint(equalToConstant: 100).isActive = true
button.centerYAnchor.constraint(equalTo: view.centerYAnchor, constant: 0).isActive = true
}
@objc func ButtonTapped() {
present(TestViewController!, animated: true, completion: nil)
TestViewController!.delegate = self
}
}


Methods “matchmakerViewControllerWasCancelled” and “matchmakerViewController” not being called inside of GKMatchmakerViewControllerDelegate
 
 
Q