---
title: NSTextViewportRenderingSurfaceKey
framework: uikit
role: symbol
role_heading: Protocol
path: uikit/nstextviewportrenderingsurfacekey
---

# NSTextViewportRenderingSurfaceKey

A protocol that lets you use an object to identify a rendering surface when storing or retrieving it.

## Declaration

```swift
protocol NSTextViewportRenderingSurfaceKey : NSObjectProtocol
```

## Overview

Overview When TextKit lays out text in a viewport, it can ask your delegate to store and retrieve rendering surfaces across layout passes. Objects that conform to NSTextViewportRenderingSurfaceKey act as the identifier for each surface — TextKit passes them to your delegate when it needs to store or look one up. Two types conform to this protocol by default: NSTextLayoutFragment — Use a layout fragment as a key to cache a rendering surface per fragment. This is the most common approach. NSString — Use a string as a key when you want to associate a rendering surface with a name rather than a fragment.

## Relationships

### Inherits From

- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

### Conforming Types

- [NSTextLayoutFragment](uikit/nstextlayoutfragment.md)

## See Also

### Layout

- [Using TextKit 2 to interact with text](uikit/using-textkit-2-to-interact-with-text.md)
- [Display text with a custom layout](uikit/display-text-with-a-custom-layout.md)
- [Managing viewport layout and attachment reuse in text views](uikit/managing-viewport-layout-and-attachment-reuse-in-a-text-view-subclass.md)
- [NSTextLayoutManager](uikit/nstextlayoutmanager.md)
- [NSTextContainer](uikit/nstextcontainer.md)
- [NSTextLayoutFragment](uikit/nstextlayoutfragment.md)
- [NSTextLineFragment](uikit/nstextlinefragment.md)
- [NSTextViewportLayoutController](uikit/nstextviewportlayoutcontroller.md)
- [NSTextViewportRenderingSurface](uikit/nstextviewportrenderingsurface.md)
- [NSTextLayoutOrientationProvider](uikit/nstextlayoutorientationprovider.md)
