- (IBAction)buttonclick1 ...
{
//You may also want to consider adding a visual cue that work is being done if it might
//take a while until the condition that you're testing becomes valid.
//If so, uncomment and implement the following:
/*
//Adds a progress view, note that it must be declared outside this method, to be able to
//access it later, in order for it to be removed
progView = [[MyProgressView alloc] initWithFrame: CGRectMake(...)];
[self.view addSubview: progView];
[progView release];
//Disables the button to prevent further touches until the condition is met,
//and makes it a bit transparent, to visually indicate its disabled state
thisButton.enabled = NO;
thisButton.alpha = 0.5;
*/
//Starts a timer to perform the verification
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 0.2
target: self
selector: @selector(buttonAction:)
userInfo: nil
repeats: YES];
}
- (void)buttonAction: (NSTimer *) timer
{
if ((value2ForIf - valueForIf) >= 3)
{
//If the condition is met, the timer is invalidated, in order not to fire again
[timer invalidate];
//If you considered adding a visual cue, now it's time to remove it
/*
//Remove the progress view
[progView removeFromSuperview];
//Enable the button and make it opaque, to signal that
//it's again ready to be touched
thisButton.enabled = YES;
thisButton.alpha = 1.0;
*/
//The rest of your code here:
}
}