_ObjectiveCBridgeable

protocol _ObjectiveCBridgeable

A Swift Array or Dictionary of types conforming to _ObjectiveCBridgeable can be passed to Objective-C as an NSArray or NSDictionary, respectively. The elements of the resulting NSArray or NSDictionary will be the result of calling _bridgeToObjectiveC on each elmeent of the source container.

Inheritance View Protocol Hierarchy →
Associated Types
_ObjectiveCType
Import import Swift

Static Methods

static func _conditionallyBridgeFromObjectiveC(_:inout:) Required

Try to bridge from an Objective-C object of the bridged class type to a value of the Self type.

This conditional bridging operation is used for conditional downcasting (e.g., via as?) and therefore must perform a complete conversion to the value type; it cannot defer checking to a later time.

result The location where the result is written.

Returns: true if bridging succeeded, false otherwise. This redundant information is provided for the convenience of the runtime's dynamic_cast implementation, so that it need not look into the optional representation to determine success.

Declaration

static func _conditionallyBridgeFromObjectiveC(source: _ObjectiveCType, inout result: Self?) -> Bool
static func _forceBridgeFromObjectiveC(_:inout:) Required

Bridge from an Objective-C object of the bridged class type to a value of the Self type.

This bridging operation is used for forced downcasting (e.g., via as), and may defer complete checking until later. For example, when bridging from NSArray to Array<T>, we can defer the checking for the individual elements of the array.

result The location where the result is written. The optional will always contain a value.

Declaration

static func _forceBridgeFromObjectiveC(source: _ObjectiveCType, inout result: Self?)
static func _getObjectiveCType() Required

Must return _ObjectiveCType.self.

Declaration

static func _getObjectiveCType() -> Any.Type
static func _isBridgedToObjectiveC() Required

Return true iff instances of Self can be converted to Objective-C. Even if this method returns true, A given instance of Self._ObjectiveCType may, or may not, convert successfully to Self; for example, an NSArray will only convert successfully to [String] if it contains only NSStrings.

Declaration

static func _isBridgedToObjectiveC() -> Bool

Instance Methods

func _bridgeToObjectiveC() Required

Convert self to Objective-C

Declaration

func _bridgeToObjectiveC() -> _ObjectiveCType