Cocoa Non-Blocking sleep wait background task

iOS Dev 30 十月 2011 | View Comments

If you have some async task running in background, and you need wait this background task until it finished, code below will help u:

 NSDate *loopUntil = [NSDate dateWithTimeIntervalSinceNow:0.1];
    while (![self isFinished] && [[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate:loopUntil]) {
        loopUntil = [NSDate dateWithTimeIntervalSinceNow:0.1];
    }


Tagged in , ,

Ads Plugin created by Jake Ruston's Wordpress Plugins - Powered by and football database.