iOS Developer Library

Developer

Foundation Framework Reference NSCachedURLResponse Class Reference

Options
Deployment Target:

On This Page
Language:

NSCachedURLResponse

Inheritance


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in iOS 2.0 and later.

An NSCachedURLResponse object represents a cached response to a URL request. It provides the server’s response metadata in the form of an NSURLResponse object, along with an NSData object containing the actual cached content data. Its storage policy determines whether the response should be cached on disk, in memory, or not at all.

Cached responses also contain a user info dictionary where you can store app-specific information about the cached item.

The NSURLCache class stores and retrieves instances of NSCachedURLResponse.

  • data data Property

    The receiver’s cached data. (read-only)

    Declaration

    Swift

    @NSCopying var data: NSData { get }

    Objective-C

    @property(readonly, copy) NSData *data

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • response response Property

    The URL response object associated with the receiver. (read-only)

    Declaration

    Swift

    @NSCopying var response: NSURLResponse { get }

    Objective-C

    @property(readonly, copy) NSURLResponse *response

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • The receiver’s cache storage policy. (read-only)

    Declaration

    Swift

    var storagePolicy: NSURLCacheStoragePolicy { get }

    Objective-C

    @property(readonly) NSURLCacheStoragePolicy storagePolicy

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • userInfo userInfo Property

    The receiver’s user info dictionary. (read-only)

    Declaration

    Swift

    var userInfo: [NSObject : AnyObject]? { get }

    Objective-C

    @property(readonly, copy) NSDictionary *userInfo

    Discussion

    nil if there is no user info dictionary.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

Data Types

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

    Declaration

    Swift

    enum NSURLCacheStoragePolicy : UInt { case Allowed case AllowedInMemoryOnly case NotAllowed }

    Objective-C

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

    Constants

    • Allowed

      NSURLCacheStorageAllowed

      Specifies that storage in NSURLCache is allowed without restriction.

      Available in iOS 2.0 and later.

    • AllowedInMemoryOnly

      NSURLCacheStorageAllowedInMemoryOnly

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

      Available in iOS 2.0 and later.

    • NotAllowed

      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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.