URLStackManager


Inherits From:
URLManager
Declared In:
URLStackManager.h


Class Description

This class manages multiple loads of URLs, much like its superclass URLManager, but this limits the number of concurrent loads and stacks up requests until a slot is available; the most recently added items are processed first. The stack can also be limited in size, causing overflow to drop off the oldest entries.

This manager does not handle HTTP POST requests that have the same URL but different request data; adding one request and then another with the same URL will cause the earlier request to be removed.

BE SURE to invoke detachConsumer on this object before deallocating this in your class's release method.


Global Variables

Synopsis:

NSString *URLStackManagerChangeNotification;


Instance Variables

NSMutableArray *mWaitingURLs;
NSMutableArray *mWaitingOptions;
NSMutableArray *mWaitingParams;
int mLoadingMax;
int mWaitingMax;

mWaitingURLsNo description.
mWaitingOptionsNo description.
mWaitingParamsNo description.
mLoadingMaxNo description.
mWaitingMaxNo description.


Method Types

Initialization and Loading
- initWithDescriptor:consumer:progress:success:cancelled:error:loaders:capacity:
- initWithDescriptor:consumer:progress:loaders:capacity:
- loadURL:options:parameter:
Status and control
- stopLoading
- stopLoadingParameter:
- isDone
- status
- stackArray

Instance Methods

initWithDescriptor:consumer:progress:loaders:capacity:

- (id)initWithDescriptor:(NSString *)inDescriptor consumer:(id)inConsumer progress:(NSProgressIndicator *)inProgress loaders:(int)inConcurrent capacity:(int)inCapacity

Initialize a URLStackManager to invoke the default methods upon completion: loadSuccess:handle:parameter:, loadCancelledParameter:, and loadError:parameter:. See initWithDescriptor:consumer:progress:success:cancelled:error:loaders:capacity.


initWithDescriptor:consumer:progress:success:cancelled:error:loaders:capacity:

- (id)initWithDescriptor:(NSString *)inDescriptor consumer:(id)inConsumer progress:(NSProgressIndicator *)inProgress success:(SEL)inSuccess cancelled:(SEL)inCancelled error:(SEL)inError loaders:(int)inConcurrent capacity:(int)inCapacity

Initialize a new URLStackManager. inDescriptor is a string to describe the purpose of the broker (for debugging uses). inConsumer is the object (another LoadBroker subclass, or any object that will respond to the completion methods) to be passed the completion methods. inSuccess, inCancelled, and inError are the selectors to invoke upon completion; these should be methods with the same signature as loadSuccess:handle:parameter:, loadCancelledParameter:, and loadError:parameter:. inConcurrent is the number of concurrent loaders that may be going at a time. inCapacity is the total number of loading and waiting URLs that may be stored before requests are lost.


isDone

- (BOOL)isDone

Returns true if done loading; that is, no loaders remain and no requests are still stacked up.


loadURL:options:parameter:

- (void)loadURL:(NSURL *)inURL options:(NSDictionary *)inOptions parameter:(id)inParam

Begin loading inURL in the background, or if the maximum number of concurrent loads is reached, stack up the load for loading as soon as possible. inOptions are passed to the URLLoader. inParam is any object that is passed back to the consumer when the load finishes so the consumer can recognize what finished loading; it might be a string, a dictionary, for example.


stackArray

- (NSArray *)stackArray

Return the waiting stack; for debugging purposes.


status

- (NSString *)status

Returns a status string; useful for debugging or displaying to the user to show how many items are still loading and how many are waiting.


stopLoading

- (void)stopLoading

Stop loading all pending and stacked-up URLs. This might be done in response to a "Cancel All" button or some such.


stopLoadingParameter:

- (void)stopLoadingParameter:(id)inParam

Stop loading url with given parameter


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