Swift: Provide transparent bridging for types with NSValue extensions
| Originator: | zwaldowski | ||
| Number: | rdar://20807093 | Date Originated: | 04-May-2015 05:43 PM |
| Status: | Open | Resolved: | false |
| Product: | Developer Tools | Product Version: | Xcode 6.3.1 (6D1002) |
| Classification: | Enhancement | Reproducible: | Sometimes |
Summary: The Apple frameworks define a number of boxing and unboxing extensions on `NSValue`. The types in question (such as `CGRect`, `CMTime`, etc.) should, in the near-term, conform to `_ObjectiveCBridgeable` and be unconditionally convertible to and conditionally convertible from an `NSArray` of an appropriate `nSValue`. Steps to Reproduce: 1. Attempt to use `AVAssetImageGenerator.generateCGImagesAsynchronouslyForTimes(_:completionHandler:)` with a `Swift.Array` of `CMTime`, or any such Objective-C method that expects an `NSArray` of an `NSValue` of a certain kind. Expected Results: The method accepts an array literal of `CMTime` instances. Actual Results: A compiler error is raised; one must manually map to `NSValue`. Version: Mac OS 10.10.4 (14E11f), Xcode 6.3.1 (6D1002), Swift 1.2 (swiftlang-602.0.49.6) Notes: An ideal longer-term solution might involve hiding the Objective-C version of the method(s) and introducing versions in an overlay library that accept instances of `SequenceType` or `CollectionType`. More conformances to `_ObjectiveCBridgeable` might have negative implications on performance or mask the meaning of `NSValue` to new Cocoa-on-Swift developers. Configuration: Occurs when boxing complex structs. Attachments:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!