How can we write " in nsstring?

后端 未结 6 556
忘了有多久
忘了有多久 2020-12-09 18:56

I have to initialize string as \"Rose\" including Quotation Mark. How to write \" in our string?

相关标签:
6条回答
  • 2020-12-09 19:21
    NSString *yourString = @"\"Rose\"";
    
    0 讨论(0)
  • 2020-12-09 19:25

    Use the escape character: \

    NSString *r = @"\"Rose\"";
    

    You can find additional information about Escape character and String literal.

    0 讨论(0)
  • 2020-12-09 19:26

    Escape it with a backslash:

    @"\"Rose\""
    
    0 讨论(0)
  • 2020-12-09 19:35

    Escape the quotation marks.

    Example:

    NSString *str = @"\"Rose\"";
    
    0 讨论(0)
  • 2020-12-09 19:40

    Escape the double quote with \

    NSString *yourString = @"\"Rose\""; 
    
    0 讨论(0)
  • 2020-12-09 19:41

    In swift 5, you can write with a hashtag :

     let raw = #"You can create "raw" strings in Swift 5."#
    

    Output :

    You can create "raw" strings in Swift 5.
    
    0 讨论(0)
提交回复
热议问题