![]() Third, in my MainViewController, I defined the prepare(for:sender:) function which would be invoked before the segue between view controllers. This is where the name would be stored when passed from the MainViewController to the SecondaryViewController. We will create the class for the second View Controller by adding a Cocoa Touch class file to our project. Second, in my SecondaryViewController, I created a variable for the child name. ![]() I researched several different methods and settled on using a segue to pass the child name between view controllers.įirst, in my MainViewController, I created a variable to access and store the child name. Accordingly, I would need to pass the name from my MainViewController to my SecondaryViewController. This is where the problem occurred… The Problemįor my project, I could only access the child name from my MainViewController and could only create my database reference in my SecondaryViewController. Events for local changes Events for metadata changes Listen to multiple documents in a collection View changes between snapshots Detach a listener. I needed to assign the child name to a variable and pass the variable into my database reference. The child name wasn’t constant though, so I couldn’t hardcode it. ![]() Take variable in VC2.swift as : var fullName : String In VC1, write. In order to successfully create the reference, I needed to know the correct child name in my database in Firebase. Draw segue from VC1 to VC2 and give identifier string InputVCToDisplayVC to segue. var number: Int Then in tabBarController's viewDidLoad, loop through the view controllers, check if they are of type ViewController, and then set their number property to the index. What you want to do is, add a property called number, or whatever you like, to your ViewController class. When storing and retrieving the user’s data, I needed to create a reference to my database. Transfer data from tab bar controller to ViewController. Photo by Maxwell Nelson on Unsplash BackgroundĪ month ago, I was working on an iOS app that used a realtime database in Firebase to more efficiently store, access, and utilize data inputted by a user. ![]()
0 Comments
Leave a Reply. |