1 Reply
      Latest reply: Nov 9, 2016 1:58 AM by eskimo RSS
      stcocoa Level 1 Level 1 (0 points)

        Hi ,

         

        I have a string value (actually html code) , and it dose have too many " <- this quotation.

         

        So, if I write that string code like a way ,  var a : String = "sdfsdfdsfdsfsdfdsf", it dose not work.

         

        (because it looks like "sadas"dsfs"vdssd"vsdvdsv"sdsdfg"" like this.

         

        It is hard to input someting like \"  manually , because a value is dynamic.

         

        Any way to do this in swift ?

        • Re: too may "s  in a String
          eskimo Apple Staff Apple Staff (7,960 points)

          Any way to do this in swift ?

          Not directly.  Support for more advanced forms of quoting is something that regularly crops up on swift-evolution.  There’s a general consensus that it’s important but there isn’t yet a plan in place to address it.

          I generally deal with this issue in one of two ways:

          • For small chunks of text, I use search and replace to add the quotes.

          • For large chunks of text, I put the text in a separate .html document in my bundle and then load that programmatically.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"