textView(_:urlForContentsOf:at:)
Returns a URL representing the document contents for a text attachment.
Declaration
@MainActor optional func textView(_ textView: NSTextView, urlForContentsOf textAttachment: NSTextAttachment, at charIndex: Int) -> URL?Parameters
- textView:
The text view sending the message.
- textAttachment:
The text attachment object containing an
NSFileWrapperobject that holds the contents of the attached file. - charIndex:
The character index of the text attachment.
Return Value
The absolute URL for the document contents represented by textAttachment.
Discussion
The returned NSURL object is used by the text view to provide default behaviors involving text attachments such as Quick Look and double-clicking. For example, the NSTextView method quickLookPreviewableItems(inRanges:) uses this method for mapping text attachments to their corresponding document URLs, and NSTextView invokes the NSWorkspace method open(_:) with the URL returned from this method when the delegate has no textView(_:doubleClickedOn:in:at:) implementation.