I think your version does not work, because the parameter "afterDelay" refers to the time of the call. You will need to multiply it by "i" in the for loop, and then use 13 and 18 respectively for the last two selectors.
Take a look at using NSOperationQueue. You can set its maxConcurrentOperationCount to 1 to ensure that it performs its actions sequentially. For instance.
NSOperationQueue * opQueue = [[NSOperationQueue alloc] init];
opQueue.maxConcurrentOperationCount = 1;
NSBlockOperation *spriteMethod1Invoker = [NSBlockOperation blockOperationWithBlock:^{
for (int i = 0; i < 5; ++i)
{
[self spriteMethod1];
sleep(2);
}
}];
NSInvocationOperation *spriteMethod2Invoker = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(spriteMethod2) object:nil];
[opQueue addOperation:spriteMethod1Invoker];
[opQueue addOperation:spriteMethod2Invoker];
source
share