URLLoader


Inherits From:
NSObject
Conforms To:
NSURLHandleClient
Declared In:
URLLoader.h


Class Description

This class is a wrapper around NSURLHandle that manages background loading in a somewhat simpler way. It assumes use of CURLHandle. It loads with a spoofed user agent of Mozilla/OmniWeb.

It is created with several parameters:

The "consumer", which is an object that should respond to the informal protocol consisting of
loadSuccess:handle:parameter:Method called when the load finishes successfully
loadSuccess:parameter:Alternate method called when the load finishes successfully
loadCancelledParameter:Method called when the load is cancelled via cancelLoadInBackground
loadError:parameter:Method called when the load fails to complete successfully

Though the above is an informal protocol, failure to respond to the above selectors will be logged as a possible leak, because the consumer must be able to handle the results.

Options is a dictionary holding any of the following keys and values:
LOAD_OPTION_HEADERSNSDictionary of additional HTTP headers to use for a request.
LOAD_OPTION_DOPOSTNSNumber of what text encoding to use for a request.
LOAD_OPTION_DOPOSTBoolean (NSNumber) of whether to force a request to be a POST.
LOAD_OPTION_CACHEBoolean (NSNumber) of whether page should be cached in memory. (Defaults to no)
LOAD_OPTION_POSTDICTNSDictionary of keys and values; if non-nil, request will be an HTTP POST.
LOAD_OPTION_POSTSTRINGNSString for a post; if non-nil, request will be an HTTP POST.
LOAD_OPTION_COOKIEDICTDictionary for a cookie; if non-nil/empty, a cookie will be set.
otherAnything else, the key should be a string of the number of the CURLOPT value, and the value will be a string. This is for arbitrary setting of many CURL options.
Parameter is any object passed into the load request that is passed back as a parameter to the completion methods for any use needed by the consumer.

If the user defaults contains a non-zero value for the key "DebugURLLoads", the load will be logged (beginning with "+++"), for debugging purposes.


Instance Variables

NSProgressIndicator *mProgress;
NSURL *mURL;
NSURLHandle *mURLHandle;
id mConsumer;
id mParameter;
int mBytesRetrievedSoFar;
BOOL mIsURLHandleClient;

mProgressNo description.
mURLNo description.
mURLHandleNo description.
mConsumerNo description.
mParameterNo description.
mBytesRetrievedSoFarNo description.
mIsURLHandleClientNo description.


Method Types

+ loadURL:consumer:options:progress:parameter:
- initWithURL:consumer:options:progress:parameter:
- loadInBackground
- cancelLoadInBackground
- urlHandle
- setProgress:


Class Methods

loadURL:consumer:options:progress:parameter:

+ (id)loadURL:(NSURL *)inURL consumer:(id)inConsumer options:(NSDictionary *)inOptions progress:(NSProgressIndicator *)inProgress parameter:(id)inParam

Creates an autoreleased instance and starts loading it. The caller must retain the URLLoader so that it is not autoreleased.


Instance Methods

cancelLoadInBackground

- (void)cancelLoadInBackground

Cancel the load.


initWithURL:consumer:options:progress:parameter:

- (id)initWithURL:(NSURL *)inURL consumer:(id)inConsumer options:(NSDictionary *)inOptions progress:(NSProgressIndicator *)inProgress parameter:(id)inParam

Initialize with the given parameters. Loading will not commence until beginLoadInBackground is invoked.


loadInBackground

- (void)loadInBackground

Start loading the URL in the background. This is invoked for you from loadURL:consumer:options:parameter:


setProgress:

- (void)setProgress:(NSProgressIndicator *)inProgress

Canonical setter: retain the new guy; release the old guy; set.


urlHandle

- (NSURLHandle *)urlHandle

Return the NSURLHandle associated with this loading; useful for setting other options before invoking beginLoadInBackground.


Version 1.1 Copyright ©2003 by Karelia Software, LLC. All Rights Reserved.