Next Page > Hide TOC

NSCachedURLResponse Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in Mac OS X v10.2 with Safari 1.0 installed.
Available in Mac OS X v10.2.7 and later.
Companion guide
Declared in
NSURLCache.h
Related sample code

Overview

An NSCachedURLResponse object encapsulates an NSURLResponse object, an NSData object containing the content corresponding to the response, and an NSDictionary containing application specific information.

The NSURLCache system stores and retrieves instances of NSCachedURLResponse.

Tasks

Creating a Cached URL Response

Getting Cached URL Response Properties

Instance Methods

data

Returns the receiver’s cached data.

- (NSData *)data

Return Value

The receiver’s cached data.

Availability
Related Sample Code
Declared In
NSURLCache.h

initWithResponse:data:

Initializes an NSCachedURLResponse object.

- (id)initWithResponse:(NSURLResponse *)response data:(NSData *)data

Parameters
response

The response to cache.

data

The data to cache.

Return Value

The NSCachedURLResponse object, initialized using the given data.

Discussion

The cache storage policy is set to the default, NSURLCacheStorageAllowed, and the user info dictionary is set to nil.

Availability
See Also
Declared In
NSURLCache.h

initWithResponse:data:userInfo:storagePolicy:

Initializes an NSCachedURLResponse object.

- (id)initWithResponse:(NSURLResponse *)response data:(NSData *)data userInfo:(NSDictionary *)userInfo storagePolicy:(NSURLCacheStoragePolicy)storagePolicy

Parameters
response

The response to cache.

data

The data to cache.

userInfo

An optional dictionary of user information. May be nil.

storagePolicy

The storage policy for the cached response.

Return Value

The NSCachedURLResponse object, initialized using the given data.

Availability
See Also
Related Sample Code
Declared In
NSURLCache.h

response

Returns the NSURLResponse object associated with the receiver.

- (NSURLResponse *)response

Return Value

The NSURLResponse object associated with the receiver.

Availability
Related Sample Code
Declared In
NSURLCache.h

storagePolicy

Returns the receiver’s cache storage policy.

- (NSURLCacheStoragePolicy)storagePolicy

Return Value

The receiver’s cache storage policy.

Availability
Related Sample Code
Declared In
NSURLCache.h

userInfo

Returns the receiver’s user info dictionary.

- (NSDictionary *)userInfo

Return Value

An NSDictionary object containing the receiver’s user info, or nil if there is no such object.

Availability
Declared In
NSURLCache.h

Constants

NSURLCacheStoragePolicy

These constants specify the caching strategy used by an NSCachedURLResponse object.

typedef enum
{
   NSURLCacheStorageAllowed,
   NSURLCacheStorageAllowedInMemoryOnly,
   NSURLCacheStorageNotAllowed,
} NSURLCacheStoragePolicy;

Constants
NSURLCacheStorageAllowed

Specifies that storage in NSURLCache is allowed without restriction.

Important: iPhone OS ignores this cache policy, and instead treats it as NSURLCacheStorageAllowedInMemoryOnly.

Available in Mac OS X v10.2 and later.

Declared in NSURLCache.h.

NSURLCacheStorageAllowedInMemoryOnly

Specifies that storage in NSURLCache is allowed; however storage should be restricted to memory only.

Available in Mac OS X v10.2 and later.

Declared in NSURLCache.h.

NSURLCacheStorageNotAllowed

Specifies that storage in NSURLCache is not allowed in any fashion, either in memory or on disk.

Available in Mac OS X v10.2 and later.

Declared in NSURLCache.h.

Availability
Declared In
NSURLCache.h

Next Page > Hide TOC


© 2008 Apple Inc. All Rights Reserved. (Last updated: 2008-05-02)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.