SingleFileDownloader Class Reference
Inherits from | NSObject |
Declared in | SingleFileDownloader.h |
Overview
@class SingleFileDownloader Class that uses NSURLConnection to download file from URL, that is set by concatanating source URL (i.e http://foo.com/files/ ) and file name (i.e. bar.png ), so URL for this file will be http://foo.com/files/bar.png , to APP_SANDBOX/Library/Caches on iOS or to ~/Library/Caches/APP_BUNDLE_ID on Mac (According to Mac OS X File System Guide ).
At the first SingleFileDownloader creates tmp file and downloads contents into it, only after downloading successfully ends – it renames tmp file to destination filename.
SingleFileDownloader is used internally in FilesDownloader class, if you’re downloading many files at time from one place – you don’t need to use SingleFileDownloader – use FilesDownloader instead.
Tasks
-
+ fileDownloaderWithSourcePath:targetFilename:delegate:
Creates SingleFileDownloader with given source path, target filename & delegate.
-
– initWithSourcePath:targetFilename:delegate:
Inits SingleFileDownloader with given source path, target filename & delegate.
-
– startDownload
Starts downloading.
-
– cancelDownload
Stops downloading.
-
+ destinationDirectoryPath
Returns shared destination path part for all files ~/Library/Caches/APP_BUNDLE_ID on Mac & APP_SANDBOX/Library/Caches on iOS.
-
– targetPath
Returns full target path for file, that will be downloaded I.e. @“APP_SANDBOX/Library/Caches/fooBar.png” (iOS) or @“~/Library/Caches/APP_BUNDLE_ID” (Mac)
-
– contentDownloaded
Returns downloaded content size in bytes.
-
– contentLength
Returns total content size in bytes. This value can be changed each. Use this method in downloadSizeUpdated delegate method to determine new expected content size.
Class Methods
destinationDirectoryPath
Returns shared destination path part for all files ~/Library/Caches/APP_BUNDLE_ID on Mac & APP_SANDBOX/Library/Caches on iOS.
+ (NSString *)destinationDirectoryPath
Declared In
SingleFileDownloader.h
fileDownloaderWithSourcePath:targetFilename:delegate:
Creates SingleFileDownloader with given source path, target filename & delegate.
+ (id)fileDownloaderWithSourcePath:(NSString *)sourcePath targetFilename:(NSString *)aTargetFilename delegate:(id<SingleFileDownloaderDelegate>)aDelegate
Parameters
- sourcePath
- path from which to download file, without filename. I.e. @“http://foo.com/files/”
- aTargetFilename
subPath that will be added to sourcePath to determine full URL for a file. I.e. @“foo/bar/file.txt”
- aDelegate
delegate for SingleFileDownloader status callbacks.
Declared In
SingleFileDownloader.h
Instance Methods
contentDownloaded
Returns downloaded content size in bytes.
- (NSUInteger)contentDownloaded
Declared In
SingleFileDownloader.h
contentLength
Returns total content size in bytes. This value can be changed each. Use this method in downloadSizeUpdated delegate method to determine new expected content size.
- (NSUInteger)contentLength
Declared In
SingleFileDownloader.h
initWithSourcePath:targetFilename:delegate:
Inits SingleFileDownloader with given source path, target filename & delegate.
- (id)initWithSourcePath:(NSString *)sourcePath targetFilename:(NSString *)aTargetFilename delegate:(id<SingleFileDownloaderDelegate>)aDelegate
Parameters
- sourcePath
- path from which to download file, without filename. I.e. @“http://foo.com/files/”
- aTargetFilename
subPath that will be added to sourcePath to determine full URL for a file. I.e. @“foo/bar/file.txt”
- aDelegate
delegate for SingleFileDownloader status callbacks.
Declared In
SingleFileDownloader.h