Mac Developer Library

Developer

Foundation Framework Reference NSURLHandle Class Reference

Options
Deployment Target:

On This Page
Language:

NSURLHandle

NSURLHandle declares the programmatic interface for an object that accesses and manages resource data indicated by an NSURL object. A single NSURLHandle can service multiple equivalent NSURL objects, but only if these URLs map to the same resource.

Cocoa provides private concrete subclasses to handle HTTP and file URL schemes. If you want to implement support for additional URL schemes, you would do so by creating a subclass of NSURLHandle. You can use NSURL and NSURLHandle to download from FTP sites without subclassing.

  • + cachedHandleForURL: (OS X v10.4) and later

    Returns the URL handle from the cache that has serviced the specified URL or another identical URL.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    + (NSURLHandle *)cachedHandleForURL:(NSURL *)aURL

    Parameters

    aURL

    The URL whose cached URL handle is desired.

    Return Value

    The URL handle from the cache that has serviced aURL or another identical URL. Returns nil if there is no such handle.

    Discussion

    Subclasses of NSURLHandle must override this method.

    Availability

    Deprecated in OS X v10.4 and later.

  • - initWithURL:cached: (OS X v10.4) and later

    Initializes a newly created URL handle with the specified URL.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    - (id)initWithURL:(NSURL *)aURL cached:(BOOL)willCache

    Parameters

    aURL

    The URL for the new handle.

    willCache

    YEStrue if the URL handle should cache its data and respond to requests from equivalent URLs for the cached data, NOfalse otherwise.

    Discussion

    Subclasses of NSURLHandle must override this method.

    Availability

    Deprecated in OS X v10.4 and later.

  • + URLHandleClassForURL: (OS X v10.4) and later

    Returns the class of the URL handle that will be used for a specified URL.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    + (Class)URLHandleClassForURL:(NSURL *)aURL

    Parameters

    aURL

    The URL in question.

    Return Value

    The class of the URL handle that will be used for aURL.

    Discussion

    Subclasses of NSURLHandle must be registered via the registerURLHandleClass: method. The subclass is determined by asking the list of registered subclasses if it canInitWithURL:; the first class to respond YEStrue is selected.

    Availability

    Deprecated in OS X v10.4 and later.

  • + canInitWithURL: (OS X v10.4) and later

    Returns whether a URL handle can be initialized with a given URL.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    + (BOOL)canInitWithURL:(NSURL *)aURL

    Parameters

    aURL

    The URL in question.

    Return Value

    YEStrue if a URL handle can be initialized with aURL, NOfalse otherwise.

    Discussion

    Subclasses of NSURLHandle must override this method to identify which URLs they can service.

    Availability

    Deprecated in OS X v10.4 and later.

  • + registerURLHandleClass: (OS X v10.4) and later

    Registers a subclass of NSURLHandle as an available subclass for handling URLs

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    + (void)registerURLHandleClass:(Class)aURLHandleSubclass

    Parameters

    aURLHandleSubclass

    The new subclass to register as an available subclass.

    Availability

    Deprecated in OS X v10.4 and later.

  • - propertyForKey: (OS X v10.4) and later

    Returns the property for the specified key.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    - (id)propertyForKey:(NSString *)propertyKey

    Parameters

    propertyKey

    The key of the desired property.

    Return Value

    The value associated with propertyKey. Returns nil if there is no such key.

    Discussion

    Subclasses of NSURLHandle must override this method.

    Availability

    Deprecated in OS X v10.4 and later.

  • - propertyForKeyIfAvailable: (OS X v10.4) and later

    Returns the property for the specified key only if the value is already available; that is, the client doesn’t need to do any work.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    - (id)propertyForKeyIfAvailable:(NSString *)propertyKey

    Parameters

    propertyKey

    The key of the desired property.

    Return Value

    The value associated with propertyKey. Returns nil if there is no such key or if the client would have to do work to fetch the property.

    Availability

    Deprecated in OS X v10.4 and later.

  • - writeProperty:forKey: (OS X v10.4) and later

    Sets the property of the receiver’s resource for a specified key to the specified value.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    - (BOOL)writeProperty:(id)propertyValue forKey:(NSString *)propertyKey

    Parameters

    propertyValue

    The new value for the property.

    propertyKey

    The key of the desired property.

    Return Value

    YEStrue if the modification was successful, NOfalse otherwise.

    Discussion

    Must be overridden by subclasses.

    Availability

    Deprecated in OS X v10.4 and later.

  • - writeData: (OS X v10.4) and later

    Attempts to write a specified set of data to the location specified by the receiver’s URL.

    Deprecation Statement

    Use NSURLConnection or NSURLDownload instead; see URL Session Programming Guide.

    Declaration

    Objective-C

    - (BOOL)writeData:(NSData *)data

    Parameters

    data

    The data to write.

    Return Value

    YEStrue if successful, NOfalse otherwise.

    Discussion

    Must be overridden by subclasses.

    Availability

    Deprecated in OS X v10.4 and later.

Data Types