Contents

ObjectiveCConvertibleAttributedStringKey

A protocol that defines Objective-C interoperability with an attribute key’s value type.

Declaration

protocol ObjectiveCConvertibleAttributedStringKey : AttributedStringKey

Overview

Conform to this protocol to allow your attributed string key to customize its Objective-C conversion behavior. This allows you to define an Objective-C value type and provide methods to convert to and from this type.

Attributed string keys that don’t conform to this protocol cast the value to AnyObject before converting to Objective-C. When converting from Objective-C, the value casts to the key’s Value type. In cases where Swift types bridge automatically to Objective-C types, like String to NSString, this default behavior is adequate. But for unbridged value types, you need to conform to this protocol and provide the conversion methods.

Topics

Accessing the Objective-C Type

Converting between Swift and Objective-C Types