Protocol

ObjectiveCConvertibleAttributedStringKey

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

Declaration 宣言

protocol ObjectiveCConvertibleAttributedStringKey

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