从Coredate加载后,步进值被重置

我正在构build一个UITabledetail视图,其中包含一个步进器和一个UILabel。

uilabel将显示按下步进器的数量。

我的问题是当我使用核心数据来保存uilabel的价值时。 例如,uilabel的最终价值是30。

当我加载数据时,uilabel显示30,但是,当我再次按下步进器时,uilabel又重置为1。

有没有办法使步进继续计数基于我保存的价值?

以下是我的代码。

- (IBAction)stepperValueChanged:(id)sender { double stepperValue = ourStepper.value; self.label.text = [NSString stringWithFormat:@"%.f", stepperValue]; } 

 - (IBAction)stepperValueChanged:(id)sender { NSString *tempString = [NSString stringWithFormat:@"30"];// you can pass here whatever data(stepper value) that you retrieve from core data... double steppervalue = [tempString doubleValue]; double stepperValue = ourStepper.value+steppervalue; self.label.text = [NSString stringWithFormat:@"%.f", stepperValue]; } 

希望对你有帮助..