Ngo Ky
Ngo Ky

Reputation: 445

how can i set time delay between two functions in iPhone?

I build app which call to server.

it takes for 20 seconds - 30 seconds to get reply from server, because the system we use depending to outside service (connecting to our partners system).

before i can do the next, i must wait to get results.

is there any way to set the delay time for waiting reply???

thanks in advance

Upvotes: 0

Views: 105

Answers (2)

Hackmodford
Hackmodford

Reputation: 3970

I use blocks in cases like these. That way you can send your request, and only proceed with code when you get a response back.

Upvotes: 1

WrightsCS
WrightsCS

Reputation: 50717

Is this what you are looking for?

performSelector

[self performSelector:@selector(doNext) withObject:nil afterDelay:30.0];

NSTimer

[NSTimer scheduledTimerWithTimeInterval:30.0 target:self selector:@selector(doNext) userInfo:nil repeats:NO];

dispatch

dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 30.0 * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
    [self doNext];
});

Upvotes: 1

Related Questions