# CachedURLResponse

> 원문 출처\
> <https://developer.apple.com/documentation/foundation/cachedurlresponse>

## Declaration

{% tabs %}
{% tab title="Swift" %}

```swift
class CachedURLResponse : NSObject
```

{% endtab %}

{% tab title="Objective-C" %}

```objectivec
@interface NSCachedURLResponse : NSObject
```

{% endtab %}
{% endtabs %}

## Summary

> **SDKs**
>
> * iOS 2.0+
> * macOS 10.2+
> * Mac Catalyst 13.0+ `Beta`
> * tvOS 9.0+
> * watchOS 2.0+
>
> **Framework**
>
> * Foundation

## 개요

CachedURLResponse 객체는 서버의 응답 메타데이터를 URLResponse 객체의 형태로 제공하며 실제 캐시 내용이 포함된 [NSData](https://melod-it.gitbook.io/sagwa/etc/not-found) 객체를 함께 제공합니다. CachedURLResponse 객체의 스토리지 정책은 응답을 디스크에 저장할 것인지 메모리에 저장할 것인지, 또는 아예 저장하지 않을 것인지를 결정합니다.

캐시된 응답은 앱에 대한 데이터를 저장할 수 있는 user info dictionary도 포함하고 있습니다.

[URLCache](https://melod-it.gitbook.io/sagwa/etc/not-found) 클래스는 CachedURLResponse 인스턴스를 저장하고 불러옵니다.

## 주제

### 캐시된 URLResponse 생성

* init(response: URLResponse, data: Data)\
  캐시된 URL response 인스턴스를 생성합니다.
* init(response: URLResponse, data: Data, userInfo: \[AnyHashable : Any]?, storagePolicy: URLCache.StoragePolicy)\
  주어진 서버 응답, 데이터, user-info dictionary와 storage 정책으로 캐시된 URL response 인스턴스를 생성합니다.

### 캐시된 URL 응답 속성

* *var* data: Data\
  캐시된 응답의 데이터
* *var* response :URLResponse\
  인스턴스와 연관된 URL response 객체
* *var* storagePolicy: URLCache.StoragePolicy\
  캐시된 응답의 스토리지 정책
* *var* userInfo: \[AnyHashable : Any]?\
  캐시된 응답의 user info dictionary

### 캐시 스토리지 정책 설정

* *enum* URLCache.StoragePolicy\
  [CachedURLResponse](https://melod-it.gitbook.io/sagwa/app-frameworks/foundation/url-loading-system/cachedurlresponse) 객체의 캐싱 전략을 지정하는 상수

관련 문서

### 상속받은 대상&#xD;

* NSObject

### 준수하는 프로토콜&#xD;

* CVarArg
* Equatable
* Hashable
* NSCopying
* NSSecureCoding

## 같이 보기

### 캐시 동작

* [캐시 데이터에 접근하기](https://melod-it.gitbook.io/sagwa/app-frameworks/foundation/url-loading-system/accessing-cached-data)\
  URL 요청시 캐시 데이터의 사용방식을 제어합니다.
* *class* [URLCache](https://melod-it.gitbook.io/sagwa/app-frameworks/foundation/url-loading-system/urlcache)\
  URL 요청을 캐시된 응답에 매핑시키는 객체


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://melod-it.gitbook.io/sagwa/app-frameworks/foundation/url-loading-system/cachedurlresponse.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
