2022. 5. 21. 01:26ㆍApple/Swift
Extended String Delimiters
You can place a string literal within extended delimiters to include special characters in a string without invoking their effect. You place your string within quotation marks (") and surround that with number signs (#). For example, printing the string literal #"Line 1\nLine 2"# prints the line feed escape sequence (\n) rather than printing the string across two lines.
If you need the special effects of a character in a string literal, match the number of number signs within the string following the escape character (\). For example, if your string is #"Line 1\nLine 2"# and you want to break the line, you can use #"Line 1\#nLine 2"# instead. Similarly, ###"Line1\###nLine2"### also breaks the line.
String literals created using extended delimiters can also be multiline string literals. You can use extended delimiters to include the text """ in a multiline string, overriding the default behavior that ends the literal. For example:
- let threeMoreDoubleQuotationMarks = #"""
- Here are three more double quotes: """
- """#
let threeMoreDoubleQuotationMarks = #"""
Here are three more double quotes: """
"""#
'Apple > Swift' 카테고리의 다른 글
[ 이메일 유효성 체크 ] - 이메일 가입이 아무거나 다된다고? (1) (0) | 2024.08.07 |
---|---|
동시성(Concurrency)을 대하는 Swift 의 자세 1 - DispatchQueue (0) | 2024.02.02 |
Swift 기본 가이드라인 - part 1 (0) | 2023.12.14 |
Macro 에 대해서 알아보자. ( 수정중 ) (0) | 2023.11.12 |
[ 구조체와 클래스 ] (0) | 2022.12.02 |