<!--
{
  "availability" : [
    "macOS: 10.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSLayoutManagerDelegate/layoutManager(_:shouldUseTemporaryAttributes:forDrawingToScreen:atCharacterIndex:effectiveRange:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(pl)NSLayoutManagerDelegate(im)layoutManager:shouldUseTemporaryAttributes:forDrawingToScreen:atCharacterIndex:effectiveRange:"
  },
  "title" : "layoutManager(_:shouldUseTemporaryAttributes:forDrawingToScreen:atCharacterIndex:effectiveRange:)"
}
-->

# layoutManager(_:shouldUseTemporaryAttributes:forDrawingToScreen:atCharacterIndex:effectiveRange:)

Asks the delegate whether to use temporary attributes when drawing the text.

```
optional func layoutManager(_ layoutManager: NSLayoutManager, shouldUseTemporaryAttributes attrs: [NSAttributedString.Key : Any] = [:], forDrawingToScreen toScreen: Bool, atCharacterIndex charIndex: Int, effectiveRange effectiveCharRange: NSRangePointer?) -> [NSAttributedString.Key : Any]?
```

## Parameters

`layoutManager`

The layout manager sending the message.

`attrs`

The temporary attributes currently in effect for the given character range.

`toScreen`

<doc://com.apple.documentation/documentation/Swift/true> if the layout manager is drawing to the screen; otherwise, <doc://com.apple.documentation/documentation/Swift/false>.

`charIndex`

Index of the first character in the range being drawn.

`effectiveCharRange`

On input and output, the effective range to which the temporary attributes apply.

## Return Value

The temporary attributes for the layout manager to use, or `nil` if no temporary attributes are to be used.

## Discussion

The default behavior, if this method is not implemented, is to use temporary attributes only when drawing to the screen, so an implementation to match that behavior would return `attrs` if `toScreen` is <doc://com.apple.documentation/documentation/Swift/true> and `nil` otherwise, without changing `effectiveCharRange`.

---

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)