Juan Munhoes Junior
Juan Munhoes Junior

Reputation: 895

Control the execution of a Function

I have an action from my UIButton that calls a function. Eg:

-(void)function:(id)sender{
    // execute some code here
}

Is this possible?

Upvotes: 0

Views: 57

Answers (1)

iDroid
iDroid

Reputation: 10533

Basically you can work with an ivar to indicate that function has not finished executing. Something like:

    BOOL isFinished;

    -(void)function:(id)sender{

            if(!isFinished) {
                // stop your process
                // start it again
                // and indicate that it's running (isFinished is still false)
            }
            else {
                isFinished = NO;
                // just start your process
            }
        }

When your function/process has finished, set isFinished = YES; from there.

Upvotes: 3

Related Questions