Thanks, I dimly recall seeing something like this before...

On Jul 4, 2009, at 12:19 PM, A.M. wrote:


On Jul 4, 2009, at 3:10 PM, Jamie Hardt wrote:
[...]
But does anyone know how to setup something like a stream read or URL download, and make sure run loop completely services the download/stream, and then write a unit test that makes sure all this happens?

NSTimeInterval timeout=3.0;
while(1)
{
        NSTimeInterval runtime=[NSDate timeIntervalSinceReferenceDate];
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate: [NSDate dateWithTimeIntervalSinceNow:t timeout];
        timeout-=[NSDate timeIntervalSinceReferenceDate]-runtime;
        if(mFileDownloaded || timeout<0.0)
                break;  
}
STAssertTrue(mFileDownloaded==YES,@"File failed to download");

Cheers,
M



_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to