How to update or send an int to the proceeding view controller

て烟熏妆下的殇ゞ 提交于 2019-12-25 01:22:31

问题


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.



来源:https://stackoverflow.com/questions/6618616/how-to-update-or-send-an-int-to-the-proceeding-view-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!