Votre question est un peu floue. Vous souhaitez compter, mais dans un ordre croissant? Voulez-vous dire augmenter la valeur au fil du temps ou la diminuer?
J'ai écrit du code pour vous aider, quelle que soit votre exigence.
@interface ViewController()
@property (strong, nonatomic) IBOutlet UITextField *textField;
@property int price;
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_price = 1000;
[NSTimer scheduledTimerWithTimeInterval:0.5 target:self selector:@selector(updatePrice) userInfo:nil repeats:YES];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)updatePrice
{
_price = _price-10; // Here I'm reducing the price by 10, add to increase the price
dispatch_async(dispatch_get_main_queue(), ^{
[_textField setText:[NSString stringWithFormat:@"%ld",_price]];
});
}