---
title: NSTextAttachmentViewProvider
framework: uikit
role: symbol
role_heading: Class
path: uikit/nstextattachmentviewprovider
---

# NSTextAttachmentViewProvider

A container object that associates a text attachment at a particular document location with a view object.

## Declaration

```swift
class NSTextAttachmentViewProvider
```

## Overview

Overview Use NSTextAttachmentViewProvider when you need to represent document locations in terms of an NSTextLocation or an NSTextRange or you want to support view-based text attachments. The view provider controls the view placement and layout without requiring view classes to be aware of the text attachment coordination using a NSTextLayoutManager in macOS 12 or iOS 15 and later.

## Topics

### Initializing a text attachment view

- [init(textAttachment:parentView:textLayoutManager:location:)](uikit/nstextattachmentviewprovider/init(textattachment:parentview:textlayoutmanager:location:).md)

### Defining the contents

- [location](uikit/nstextattachmentviewprovider/location.md)
- [textAttachment](uikit/nstextattachmentviewprovider/textattachment.md)
- [textLayoutManager](uikit/nstextattachmentviewprovider/textlayoutmanager.md)
- [tracksTextAttachmentViewBounds](uikit/nstextattachmentviewprovider/trackstextattachmentviewbounds.md)
- [view](uikit/nstextattachmentviewprovider/view.md)

### Defining a custom view hierarchy

- [loadView()](uikit/nstextattachmentviewprovider/loadview().md)

### Determining the Attachment’s Bounds

- [attachmentBounds(for:location:textContainer:proposedLineFragment:position:)](uikit/nstextattachmentviewprovider/attachmentbounds(for:location:textcontainer:proposedlinefragment:position:).md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Attachments

- [NSTextAttachment](uikit/nstextattachment.md)
- [NSAdaptiveImageGlyph](uikit/nsadaptiveimageglyph.md)
- [NSTextAttachmentContainer](uikit/nstextattachmentcontainer.md)
- [NSTextAttachmentLayout](uikit/nstextattachmentlayout.md)
