【问题标题】:how to sum temporary variables's value in xcode如何在xcode中对临时变量值求和
【发布时间】:2014-04-22 21:10:16
【问题描述】:

我希望 TempScore 在保存并与旧值一起添加到 Score 变量后立即返回 0

if (self.currentQuestion < [self.questions count]) {


_TempScore = x;
_Score = y;
_Score = x + y;
x = 0;
}

为什么这不起作用?

编辑:让它工作

self.x = self.TempScore;

self.y = self.Score;

self.Score = self.x + self.y ;

self.TempScore = 0;

【问题讨论】:

  • self.Score 与 _Score 相同,但不调用 setter。 self.TempScore 和 _TempScore 具有类似的相关性。不确定您到底要做什么,但请记住这一点。
  • 谢谢我粘贴了一些我忘记剪掉的旧行
  • @lea51294 你想做什么?您只是将_TempScore_Score 设置为0
  • 我希望 tempscore 在保存并将旧值添加到 score 变量中后立即返回 0
  • 你明白我想做什么了吗?

标签: xcode variables sum temporary


【解决方案1】:

通过这样做使其工作

self.x = self.TempScore;
self.y = self.Score;
self.Score = self.x + self.y ;
self.TempScore = 0;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-21
    • 1970-01-01
    • 1970-01-01
    • 2018-11-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多