Reputation: 1410
Is there a way to send data between ViewControllers without using segues?
Specifically I have two ViewControllers embedded in a TabBarViewController. One is called PlayingCardViewController and the other is called HighScoreViewController. I want to pass a class HighScore from PlayingCardViewController to HighScoreViewController. I want to transfer the data from PlayingCardViewController as soon as I press the redeal button in PlayingCardViewController but I don't want to transition to the HighScoreViewController as that would be jarring for the player.
I thought about using segues and holding the HighScores in an array and passing that to all the VC's that PlayingCardViewController is connected to but I realized that that seems overly complicated and there must be a simpler way to pass the data upon hitting the redeal button.
Some relevant links Passing Data between View Controllers
Upvotes: 0
Views: 85
Reputation: 2751
I'm just going to do this with bullet points:
UITabBarController
subclass), and use this instead of a basic UITabBarController
.PlayingCardViewController
could have its own delegate protocol/property. playingCardVC:didSetHighScore:
.PlayingCardViewController
's delegate.HighScoreViewController
.playingCardVC:didSetHighScore:
, it could pass whatever you want to your HighScoreViewController
.Upvotes: 1