vendredi 10 février 2017

Pass String between 2 View Controllers in a Tab Bar

Vote count: 0

I have a Swift App that uses Firebase. On this part of the app there are 2 VC's that are in a Tab Bar Controller then a Navigation Controller. So TBC -> NavC -> VC.

I need to pass a string from the main TBC VC. It is a firebase ID for a card. Using that ID I can access all of the children on that card's node, but without it I am unable.

I have tried using prepareForSegue..

let tabVc = segue.destination as! UITabBarController
let navVc = tabVc.viewControllers!.first as! UINavigationController
let destinationVC = navVc.viewControllers.first as! MonthlyNutViewController

destinationVC.cardID = cardID
print(cardID)

I have set a breakpoint on that and it doesn't hit.

I have seen a few older SO posts suggesting that I create a global variable in the appDelegate, but I thought that was frowned upon.

What will be the best way for me to transfer that string? Thank you.

asked 20 secs ago

Let's block ads! (Why?)



Pass String between 2 View Controllers in a Tab Bar

Aucun commentaire:

Enregistrer un commentaire