How should I make data available to all of my views?

Trevör

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 ?

Rashad

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Rails: How can I make an object available in all views?

From Dev

how do i make session variables available through out all controllers and views in cakephp 3.2

From Dev

How to make @current_user available in my views?

From Dev

How to make my sql data available for all new transactions in my Junit?

From Dev

How can I make common search code available to all of my model classes?

From Dev

Should I split my Views up into a lot of small Views or just make it one big View?

From Dev

Should I split my Views up into a lot of small Views or just make it one big View?

From Dev

How should I make my parser concurrent?

From Dev

How should i deploy all my APIs?

From Dev

How can I make a link to the result of a model method in my views?

From Dev

How to store data from Pubnub history and make it available to all controllers?

From Dev

Singleton Use - How to make Data Available to all Classes?

From Dev

How can I make the LLVM IR of a function available to my program?

From Dev

How can I make my webserver running on android publically available

From Dev

How can I make the LLVM IR of a function available to my program?

From Dev

How is Html helper 'available' to all views in MVC?

From Dev

ASP MVC Make Class Namespace Available In All Views

From Dev

How do I make a data file available to unit tests?

From Dev

How big should I make my swap partition?

From Dev

How should I handle a Rails model record that my controller and views rely on?

From Dev

How should I handle a Rails model record that my controller and views rely on?

From Dev

How do I tell my Views when they should unsubscribe from events?

From Dev

How do I make my javascript method available to my other backbone methods?

From Dev

How can I make my tftp server visible/available on my local network?

From Dev

linux: How can I view all UUIDs for all available disks on my system?

From Dev

How should I structure/pass my data or actions in redux

From Dev

What should I use to make sure my CSS works with all browsers?

From Dev

R how to make my package available online

From Dev

How to make my CMMotionManager available through a singleton?

Related Related

  1. 1

    Rails: How can I make an object available in all views?

  2. 2

    how do i make session variables available through out all controllers and views in cakephp 3.2

  3. 3

    How to make @current_user available in my views?

  4. 4

    How to make my sql data available for all new transactions in my Junit?

  5. 5

    How can I make common search code available to all of my model classes?

  6. 6

    Should I split my Views up into a lot of small Views or just make it one big View?

  7. 7

    Should I split my Views up into a lot of small Views or just make it one big View?

  8. 8

    How should I make my parser concurrent?

  9. 9

    How should i deploy all my APIs?

  10. 10

    How can I make a link to the result of a model method in my views?

  11. 11

    How to store data from Pubnub history and make it available to all controllers?

  12. 12

    Singleton Use - How to make Data Available to all Classes?

  13. 13

    How can I make the LLVM IR of a function available to my program?

  14. 14

    How can I make my webserver running on android publically available

  15. 15

    How can I make the LLVM IR of a function available to my program?

  16. 16

    How is Html helper 'available' to all views in MVC?

  17. 17

    ASP MVC Make Class Namespace Available In All Views

  18. 18

    How do I make a data file available to unit tests?

  19. 19

    How big should I make my swap partition?

  20. 20

    How should I handle a Rails model record that my controller and views rely on?

  21. 21

    How should I handle a Rails model record that my controller and views rely on?

  22. 22

    How do I tell my Views when they should unsubscribe from events?

  23. 23

    How do I make my javascript method available to my other backbone methods?

  24. 24

    How can I make my tftp server visible/available on my local network?

  25. 25

    linux: How can I view all UUIDs for all available disks on my system?

  26. 26

    How should I structure/pass my data or actions in redux

  27. 27

    What should I use to make sure my CSS works with all browsers?

  28. 28

    R how to make my package available online

  29. 29

    How to make my CMMotionManager available through a singleton?

HotTag

Archive