---
title: "viewProvider(for:location:textContainer:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/nstextattachmentlayout/viewprovider(for:location:textcontainer:)"
---

# viewProvider(for:location:textContainer:)

Returns the text attachment view provider corresponding to the file type.

## Declaration

```swift
func viewProvider(for parentView: UIView?, location: any NSTextLocation, textContainer: NSTextContainer?) -> NSTextAttachmentViewProvider?
```

## Parameters

- `parentView`: The parent view.
- `location`: An doc://com.apple.uikit/documentation/UIKit/NSTextLocation that indicates that start of the string.
- `textContainer`: The doc://com.apple.uikit/documentation/UIKit/NSTextContainer that contains the source text.

## Return Value

Return Value An NSTextAttachmentViewProvider.

## Discussion

Discussion The default implementation queries the text attachment view provider class using the textAttachmentViewProviderClass(forFileType:) method of NSTextAttachment. When non-nil, it instantiates a view, then, fills properties declared in NSTextAttachmentViewProvider if implemented.

## See Also

### Determining the characteristics of an attachment

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