출처
앱 12개를 만들며 배우는 Swift4 & iOS11 아이폰 iOS 개발 강좌
위치
iBooks > swift 5 검색
내용
- String Literals
- let someString = "Input Some String"
- Multiline String Literals : """ """
let quotation = """
The White Rabbit put on his spectacles. "Where shall I begin,
please your Majesty?" he asked.
"Begin at the beginning," the King said gravely, "and go on
till you come to the end; then stop."
""
- Escaped special characters
- \n
- \"
- \r
- 등등
- Empty String 할당하기
- 방법1 ) var emptystring = ""
- 방법2 ) var emptystring = String()
- Concatenating Strings & Characters
- 방법1 ) var welcome = string1 + string2
- 방법2 ) instruction += string2
- Counting Characters
- print((변수명.count))
예제
import UIKit
// 여러 줄 출력하기
var str = "Hello, playground.\nNice to meet you \n\"I'm ddaengddaeng\""
print(str)
var str2 = """
Hello, playground.
Nice to meet you
\"I'm ddaengddaeng\"
"""
print(str2)
// empty string
var emptyString = ""
var anotherEmptyString = String()
if emptyString.isEmpty {
print("Nothing to see here")
}
// concatenate
let string1 = "hello"
let string2 = " there"
var welcome = string1 + string2
print(welcome)
var instruction = "look over"
instruction += string2
print(instruction)
// count
print(instruction.count)
'iOS' 카테고리의 다른 글
[Swift] If, Switch 문 (0) | 2020.07.03 |
---|---|
[Swift] For, While 문 (0) | 2020.07.03 |
[Swift] Basic Operator (기본 연산자) (0) | 2020.07.03 |
[Swift] Collection (Array, Set, Dictionary) (0) | 2020.07.03 |
[Swift] Constant, Variable (0) | 2020.07.02 |
댓글