Skip to content

Instantly share code, notes, and snippets.

@dodikk
Created November 29, 2013 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dodikk/7708728 to your computer and use it in GitHub Desktop.
Save dodikk/7708728 to your computer and use it in GitHub Desktop.
Download to tmp file handling
-(void)URLSession:(NSURLSession *)session
downloadTask:(NSURLSessionDownloadTask *)downloadTask
didFinishDownloadingToURL:(NSURL *)location
{
NSParameterAssert( nil != location );
if ( self->_shouldCopyTmpFileToCaches )
{
JFFAsyncOperation asyncCopy = [ [ self class ] asyncCopyFileToCaches: location ];
asyncCopy( nil, nil, ^void( NSURL* tmpFileInCaches, NSError* copyError )
{
[ self onSuccessfulDownloadToTmpFile: tmpFileInCaches
copyFileError: copyError ];
} );
}
else
{
[ self onSuccessfulDownloadToTmpFile: location
copyFileError: nil ];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment