ios - Passing user data through view controllers -
this question has answer here:
- passing data between view controllers 35 answers
i'm making basic app allows user login.
i wanted know general practice of passing user data between view controllers. after user authenticated, acceptable pass data through view controllers?
for example, user logged in , authenticated. user wants "create event", able save user hosting event, have store users id on event host , need access uid. save users id after login , keep passing in every view?
i using firebase backend if helps.
you should learn thing called "segues". primary mechanism transition between views in ios.
here's tutorial(no personal affiliation, btw) http://makeapppie.com/2014/07/01/swift-swift-using-segues-and-delegates-in-navigation-controllers-part-1-the-template/
haven't used firebase, if passing event data scratch 4 things.
- would declare var in target controller.
- in source controller fire off function: performseguewithidentifier @ appropriate time.
- that takes prepareforsegue function (the contents of func last point of no return before transition new controller). inside, create var name of type name of target view controller.
- use dot operators access variable want pass , give appropriate value
Comments
Post a Comment