I have hit a wall with my design. I am trying to pass the strings from one View Controller to another. Those 2 controllers are not connected with segue. I have attached the screenshoot of my Storyboard. I have a feeling that my only option is to use a Singleton, or would that be possible with delegates? without using the method:
override func prepare(for segue: UIStoryboardSegue, sender: Any?)
I can not acces the VC1 by the segue identifier. How would that be possible without accessing the identifier?
Please have a look at the image and let me know what options do I have and what would be the best to use here.
If its a small data like some string or variable you can use UserDefault or pass data using that class variable like vc2.data = data How to use UserDefaults How to use UserDefaults in swift?
If its more like table or number of user list you can use plist store in your bundle at can retrieve from any view controller using Plist How do I get a plist as a Dictionary in Swift?
if two controller are some how connected you can use delegates. delegats:- Delegates in swift?
You can also use notifications if you are not sure when data will be available/ or send base on some action, or send if something is trigged.
Pass data using Notifications How to pass data using NotificationCentre in swift 3.0 and NSNotificationCenter in swift 2.0?
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments