Skip to content

Commit 322a990

Browse files
committed
stdlib: add SPI for bridging for Foundation
1 parent e773c71 commit 322a990

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

stdlib/public/SDK/Foundation/Foundation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ extension Array : _ObjectiveCBridgeable {
414414

415415
@_semantics("convertToObjectiveC")
416416
public func _bridgeToObjectiveC() -> NSArray {
417-
return unsafeBitCast(self._buffer._asCocoaArray(), to: NSArray.self)
417+
return unsafeBitCast(self._bridgeToObjectiveCImpl(), to: NSArray.self)
418418
}
419419

420420
public static func _forceBridgeFromObjectiveC(

stdlib/public/core/Arrays.swift.gyb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,11 @@ public func != <Element : Equatable>(
20742074

20752075
#if _runtime(_ObjC)
20762076
extension Array {
2077+
public // @SPI(Foundation)
2078+
func _bridgeToObjectiveCImpl() -> AnyObject {
2079+
return _buffer._asCocoaArray()
2080+
}
2081+
20772082
/// Tries to downcast the source `NSArray` as our native buffer type.
20782083
/// If it succeeds, creates a new `Array` around it and returns that.
20792084
/// Returns `nil` otherwise.

0 commit comments

Comments
 (0)