<!--
{
  "availability" : [
    "macOS: 12.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSTextLayoutManagerDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSTextLayoutManagerDelegate"
  },
  "title" : "NSTextLayoutManagerDelegate"
}
-->

# NSTextLayoutManagerDelegate

Optional methods that delegates implement to respond to layout changes.

```
protocol NSTextLayoutManagerDelegate : NSObjectProtocol
```

## Overview

Optional methods that delegates implement to respond to layout changes.

## Topics

### Responding to layout changes

[`func textLayoutManager(NSTextLayoutManager, renderingAttributesForLink: Any, at: any NSTextLocation, defaultAttributes: [NSAttributedString.Key : Any]) -> [NSAttributedString.Key : Any]?`](/documentation/AppKit/NSTextLayoutManagerDelegate/textLayoutManager(_:renderingAttributesForLink:at:defaultAttributes:))

Returns a dictionary of rendering attributes for rendering a link.

[`func textLayoutManager(NSTextLayoutManager, shouldBreakLineBefore: any NSTextLocation, hyphenating: Bool) -> Bool`](/documentation/AppKit/NSTextLayoutManagerDelegate/textLayoutManager(_:shouldBreakLineBefore:hyphenating:))

Invoked while determining the soft line break point.

[`func textLayoutManager(NSTextLayoutManager, textLayoutFragmentFor: any NSTextLocation, in: NSTextElement) -> NSTextLayoutFragment`](/documentation/AppKit/NSTextLayoutManagerDelegate/textLayoutManager(_:textLayoutFragmentFor:in:))

Returns a text layout fragment for the specified location in the text element.

### Instance Methods

[`func textLayoutManager(NSTextLayoutManager, cacheTextAttachmentViewProvider: NSTextAttachmentViewProvider, for: NSTextAttachment)`](/documentation/AppKit/NSTextLayoutManagerDelegate/textLayoutManager(_:cacheTextAttachmentViewProvider:for:))

Notifies the delegate that a view provider associated with a text attachment is about to be invalidated.

[`func textLayoutManager(NSTextLayoutManager, retrieveCachedTextAttachmentViewProviderFor: NSTextAttachment) -> NSTextAttachmentViewProvider?`](/documentation/AppKit/NSTextLayoutManagerDelegate/textLayoutManager(_:retrieveCachedTextAttachmentViewProviderFor:))

Returns a cached `NSTextAttachmentViewProvider` to be associated with a particular attachment.

## Relationships

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)