NSCachedURLResponse Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in iOS 2.0 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
  • Available in iOS 2.0 and later.
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
  • Available in iOS 2.0 and later.
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
  • Available in iOS 2.0 and later.
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
  • Available in iOS 2.0 and later.
Declared In
NSURLCache.h

storagePolicy

Returns the receiver’s cache storage policy.

- (NSURLCacheStoragePolicy)storagePolicy
Return Value

The receiver’s cache storage policy.

Availability
  • Available in iOS 2.0 and later.
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
  • Available in iOS 2.0 and later.
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: iOS prior to version 5 ignores this cache policy, and instead treats it as NSURLCacheStorageAllowedInMemoryOnly.

Available in iOS 2.0 and later.

Declared in NSURLCache.h.

NSURLCacheStorageAllowedInMemoryOnly

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

Available in iOS 2.0 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 iOS 2.0 and later.

Declared in NSURLCache.h.

Availability
  • Available in iOS 2.0 and later.
Declared In
NSURLCache.h

Did this document help you? Yes It's good, but... Not helpful...