String doesn't conform to NSCopying

I'm getting lots of errors now that String doesn't conform to things like NSCopying or NSSecureCoding. Am I *really* supposed to have to start sprinkling "as NSString" in my Swift code, or is this a bug I should report?


For example, the Contacts framework wants a "ValueType : NSCopying, NSSecureCoding>" for its CNLabeledValue parameters.

Replies

The automatic (implicit) bridging is no more. You'll need the 'as' to now bridge explicity. See Swift evolution 0072 (eliminate-implicit-bridging-conversions) for details.

Am I really supposed to have to start sprinkling "as NSString" in my Swift code, or is this a bug I should report?

You should definitely file a bug about this. While rsharp is correct that implicit bridging is gone per SE-0072, it’s clearly a pain to have to sprinkle NSStrings everywhere in your code. Normally I avoid problems like this by adding an extension (see this post) but in this case I couldn’t make that work due to the Extension of a generic Objective-C class cannot access the class's generic parameters at runtime error.

Please post your bug number, just for the record.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"