If I have this method:
-(void) methodName
{
action1;
action2;
[self methodName];
}
I want the [self methodName] call to be done only once, therefore the method to be called only twice consecutively. Can this be done? Not sure where in the docs I should be looking.
Whenever method ‘methodName’ is called, then when action1 and action2 are done, it should call itself again, but only once. The way it is done in the sample code I have written is going on forever (I am guessing).
If you mean to say only once during the entire lifetime of the application, you can use
dispatch_once, like this:If, however, you meant for the method to execute
action1andaction2twice per invocation, you have two options:1) Wrap that functionality in another method:
2) Even simpler, wrap it in a loop: