Inherits from NSObject
Declared in DTDownload.h

Overview

A Class that represents a download of a file from a remote server. It also supports only getting a HEAD on the given URL and optionally resume an interrupted download

Properties

URL

Returns the URL that is being downloaded by the receiver.

@property (nonatomic, strong, readonly) NSURL *URL

Declared In

DTDownload.h

additionalHTTPHeaders

Using for HTTP headers parameters. For example, basic http authentification

@property (nonatomic, copy) NSDictionary *additionalHTTPHeaders

Declared In

DTDownload.h

completionHandler

Sets the block to execute as soon as the download has completed.

@property (nonatomic, copy) DTDownloadCompletionHandler completionHandler

Declared In

DTDownload.h

contentType

Returns the MIME type of the downloading file.

@property (nonatomic, strong, readonly) NSString *contentType

Declared In

DTDownload.h

context

Use to set or retrieve an object that provides a context for the download.

@property (nonatomic, strong) id context

Declared In

DTDownload.h

delegate

Returns the receiver’s delegate.

@property (nonatomic, assign) id<DTDownloadDelegate> delegate

Declared In

DTDownload.h

downloadEntityTag

Returns the entity tag of the downloading file.

@property (nonatomic, strong, readonly) NSString *downloadEntityTag

Declared In

DTDownload.h

expectedContentLength

Returns the number expected content bytes of the downloading file.

@property (nonatomic, assign, readonly) long long expectedContentLength

Discussion

If the headers did not specify a content length to expect then this value is -1

Declared In

DTDownload.h

lastModifiedDate

Returns the last modified date of the downloading file.

@property (nonatomic, strong, readonly) NSDate *lastModifiedDate

Declared In

DTDownload.h

responseHandler

Sets the block to execute as soon as the HTTP response has been received and the headers are available.

@property (nonatomic, copy) DTDownloadResponseHandler responseHandler

Declared In

DTDownload.h

Class Methods

downloadForURL:atPath:

Creates a download for a given URL at the given path If a previous uncompleted download at the destination location exists then the download is tried to resumed, otherwise a new full download is performed.

+ (DTDownload *)downloadForURL:(NSURL *)URL atPath:(NSString *)path

Parameters

URL

The remote URL to download

path

The path to download to

Return Value

a new DTDownload instance

Declared In

DTDownload.h

Instance Methods

canResume

YES if the download can be resumed, otherwise no

- (BOOL)canResume

Return Value

YES if the download can be resumed, otherwise no

Declared In

DTDownload.h

cleanup

Removes the downloaded file or the incomplete file if the download is currently running. Note: Also the download is cancelled if necessary

- (void)cleanup

Declared In

DTDownload.h

initWithURL:

Creates a download for a given URL.

- (id)initWithURL:(NSURL *)url

Parameters

url

A remote URL

Return Value

An initialized download object

Declared In

DTDownload.h

initWithURL:withDestinationFile:

Creates a download for a given URL and stores the result to the file

- (id)initWithURL:(NSURL *)url withDestinationFile:(NSString *)destinationFile

Parameters

url

A remote URL

destinationFile

where the downloaded file should be stored

Return Value

An initialized download object

Declared In

DTDownload.h

initWithURL:withDestinationPath:

Creates a download for a given URL and stores the result to the destination path with the filename that provided by the webserver. The the webserver does provide a filename then the last path component of the URL is used.

- (id)initWithURL:(NSURL *)url withDestinationPath:(NSString *)destinationPath

Parameters

url

A remote URL

destinationPath

where the downloaded file should be stored

Return Value

An initialized download object

Declared In

DTDownload.h

isRunning

Determines if the download is currently in progress

- (BOOL)isRunning

Declared In

DTDownload.h

start

Starts or Resumes a download for a given URL.

- (void)start

Declared In

DTDownload.h

startHEAD

Starts a HEAD request for the given URL. This retrieves the headers and not the body of the document.

- (void)startHEAD

Declared In

DTDownload.h

stop

Stops a download in progress

- (void)stop

Declared In

DTDownload.h