【发布时间】:2012-06-27 22:04:28
【问题描述】:
我希望有一个系统,如果用户在多项选择题中得到正确答案,它会更新用户的分数。我有一个 IBAction,当用户选择正确的选择并且我希望它更新分数时运行。 即答案正确时得分+ 2 是 CGFloat 还是 NSInteger 的东西?
【问题讨论】:
我希望有一个系统,如果用户在多项选择题中得到正确答案,它会更新用户的分数。我有一个 IBAction,当用户选择正确的选择并且我希望它更新分数时运行。 即答案正确时得分+ 2 是 CGFloat 还是 NSInteger 的东西?
【问题讨论】:
试试这样的:
//.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 方法即可。希望这会有所帮助!
【讨论】: