【问题标题】:What is the easiest way to keep track of scores?记录分数的最简单方法是什么?
【发布时间】:2012-06-27 22:04:28
【问题描述】:

我希望有一个系统,如果用户在多项选择题中得到正确答案,它会更新用户的分数。我有一个 IBAction,当用户选择正确的选择并且我希望它更新分数时运行。 即答案正确时得分+ 2 是 CGFloat 还是 NSInteger 的东西?

【问题讨论】:

    标签: ios nsinteger cgfloat


    【解决方案1】:

    试试这样的:

    //.h File
    @property (nonatomic) NSUInteger score; //If the user can get a negative score, change "NSUInteger" to "NSInteger"
    -(void)scoreChanged;
    
    //.m File
    -(void)scoreChanged{
        self.score += 2; //You can change the 2 to any number
    }
    
    //viewDidLoad
    self.score = 0;
    

    无论您想在哪里更新分数,只需调用scoreChanged 方法即可。希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2010-09-08
      • 1970-01-01
      • 1970-01-01
      • 2018-02-09
      • 2018-04-12
      • 1970-01-01
      • 1970-01-01
      • 2011-01-03
      相关资源
      最近更新 更多