Let's say that I have an app that has multiple UIView
(for example "tab views"), but all of these views are using the same data to display things, of course I don't want to load it again for each view.
I could transmit the data using segues but since these views aren't really related hierarchically (the data each UIView
will be using wasn't generated by the other UIView
), it would feel more logic to me if I had variables that would get their content in the applicationDidFinishedLaunching
(for example) and then if these variables could be accessible to each of my views.
How should I do that ? Is there a way that's more recommended by Apple ?
Declare property in .h file, like :
@property (strong, nonatomic) NSString *testName;
Form any other class do this:
let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
let aVariable = appDelegate.testName
Hope this helps.. :)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments