I have an app that give a player a score. The player can then go to a rewards area and use some or all of that score to purchase rewards. What is the best way use a variable that stores the score earned from the first viewController to purchase rewards in the second viewController and update the score variable on the first viewController when earned score points are spent ( it is possible to only spend a portion of those points, so I would need to subtract only the points spent from the score variable in first viewController )–Basically I need to access the same variable on 2 viewControllers–is it a delegate or is there a better way
Like anything with programming there’s a million ways to do it.
You can use a delegate to pass a variable back and fourth.
Or you could even create a JSON file with your score or anything else you want in it, and just read/write from it on each view controller.