如何更新int或将int发送给进行中的视图控制器 [英] How to update or send an int to the proceeding view controller

查看:86
本文介绍了如何更新int或将int发送给进行中的视图控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个测验应用程序,在回答每个问题后,您会在UILabel中为您评分,因此我有一个按钮,当您按正确答案获得10分,如果按错答案则获得0分,但是我如何将int得分值带到由navController推送的下一个问题.

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.

此外,如果有人知道每次回答问题都比更新每个视图的得分更好的问题时,只更新测验的最后一个视图(ScoreView)的方法

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

推荐答案

您可以在 app委托中声明 int属性,并且您可以更新或从您的应用程序中的任何地方读取它.您无需承担额外的负担即可将结果从第一个视图控制器一直传递到最后一个视图控制器.

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.

这篇关于如何更新int或将int发送给进行中的视图控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆