Hello!

I translate Data in String thus:

 let responseData = String(data: urlData!, encoding: .utf8) 

when outputting via print , the line looks like this (the one that suits me):

print(responseData) -> "dizt7yyFGaKeHTEWDA="

but the variable contains it (the same thing shows po to the log):

"\"dizt7yyFGaKeHTEWDA=\""

what could be the problem?

    1 answer 1

    So all is true. To display quotes you need to add \" , which is why print displays the result in quotes.

    Example:

     print("\"Π₯ΠΎΡ€ΠΎΡˆΠΈΠ΅ Ρ…ΡƒΠ΄ΠΎΠΆΠ½ΠΈΠΊΠΈ ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚, Π²Π΅Π»ΠΈΠΊΠΈΠ΅ Ρ…ΡƒΠ΄ΠΎΠΆΠ½ΠΈΠΊΠΈ ΠΊΡ€Π°Π΄ΡƒΡ‚\" - Пабло Пикассо") 

    Result:

    "Π₯ΠΎΡ€ΠΎΡˆΠΈΠ΅ Ρ…ΡƒΠ΄ΠΎΠΆΠ½ΠΈΠΊΠΈ ΠΊΠΎΠΏΠΈΡ€ΡƒΡŽΡ‚, Π²Π΅Π»ΠΈΠΊΠΈΠ΅ Ρ…ΡƒΠ΄ΠΎΠΆΠ½ΠΈΠΊΠΈ ΠΊΡ€Π°Π΄ΡƒΡ‚" - Пабло Пикассо

    To remove quotes: string.replacingOccurrences(of: "\"", with: "", options: NSString.CompareOptions.literal, range:nil)

    • Thanks for the quick response, how best to get rid of quotes and slashes? because trimming the first and last character looks like a crutch - pbogdanv
    • So you need to get an answer without quotes? Like this: dizt7yyFGaKeHTEWDA = - Vitali Eller
    • yes, just a string, in the form of dizt7yyFGaKeHTEWDA = - pbogdanv
    • edited the answer. The function searches for all the quotes in the string and deletes them. - Vitali Eller
    • Thanks, now you can work with this line) - pbogdanv