2 Replies
      Latest reply: Sep 11, 2016 8:24 AM by eskimo RSS
      Gargoyle Level 2 Level 2 (50 points)

        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. 

        • Re: String doesn't conform to NSCopying
          rsharp Level 3 Level 3 (145 points)

          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.

          • Re: String doesn't conform to NSCopying
            eskimo Apple Staff Apple Staff (7,005 points)

            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"