How to update or send an int to the proceeding vie

2019-08-21 00:35发布

问题:

Hi I have a quiz app that gives you a score in a UILabel after answering each question, so I have a button that when you hit the correct answer you get 10 points and if hit the wrong answer you get 0 points, but how do I bring the int score value to the next question, which is pushed by a navController.

Also if anyone knows a way to just have the last view (ScoreView) of the quiz be updated every time you answer the question that would be better than updating the score on every view

回答1:

You can declare an int property in the app delegate, and you can update or read it from anywhere in your application. You have no need to take the extra burden to carry the result from the first view controller all the way to the last view controller.