목차 Optionals (옵셔널) Optionals (옵셔널) Unwrapping (언래핑) Forced Unwrapping! (강제추출!) Optional 특징 Optional Binding (옵셔널 바인딩) If let / while let / guard let Implicitly Unwrapped Optionals (IUO, 암시적 추출 옵셔널!) Nil-Coalescing Operator (Nil 병합 연산자, ??) Optionals (옵셔널) Optionals은 값이 없다는 뜻으로 nil로 표기한다. Optionals 선언 및 예시 let optionalNum: Int? = nil // 자료형 뒤에 공백없이 '?'을 붙이면 옵셔널이 된다. let optionalNum = nil // error..
목차 Control Transfer Statements (흐름 제어 구문) break Statement continue Statement Labeled Statement (구문 이름표) Control Transfer Statements (흐름 제어 구문) 제어를 전달한다는 것은 현재 실행중인 scope 중에서 break, continue, Labeled 등을 통해 코드의 흐름을 제어하여 바로 다음 코드를 실행하게 하는 것이다. break Statement let num = 1 // switch문에서 break switch num { case 1...100: print("num은 \(num)이다.") // num은 1이다. if num % 2 != 0 { // num = 1이므로 break break } ..
목차 For-In Loops (for문) for문 이중 for문 Wildcard Pattern while Loop (while문) while repeat-while While Loop 특징 For-In Loops (for문) for문 이중 for문 '_' (underbar) Wildcard Pattern for문 for loopConstant in Range { statements } 예시 for index in 1 ... 3 { print("Hello, World") } /* Hello, World Hello, World Hello, World */ for index in 1 ... 3 { print(index) } /* 1 2 3 */ for num in stride(from: 0, to: 5, by..
목차 if Statement (if문) if else else-if switch Statements switch case switch case where guard Statements if Statement (if문) if else else-if If if condition { statements } let id = "patrick" let password = "1234" if id == "patrick" { print("valid id") // vaild id } if password == "1234" { print("vaile password") // vaild password } else if condition { statements } else { statements } if id == "patr..
목차 Operator Basics (연산자 기초) Arithmetic Operators (산술 연산자) Overflow Operators (오버플로우 연산자) Comparison Operators (비교 연산자) Logical Operators (논리 연산자) Ternary Conditional Operator (삼항 연산자) Assignment Operators (할당 연산자) Range Operators (범위 연산자) Operator Basics (연산자 기초) Operator (연산자), Operand (피연산자), Whitespaces (공백) Unary Operator (단항 연산자) Binary Operator (이항 연산자) Ternary Operator (삼항 연산자) Prefix Ope..
목차 Data Types with Memory Data Types Memory Overflow Numbers Number Literals (숫자 리터럴) Integer Types Signed vs Unsigned Int & UInt Floating-point Types Boolean Strings and Characters (문자열과 문자) Bool, Int, UInt, Float, Double, Charcter, String 비교 Type Inference (형식 추론) Type Inference Rules Type Annotation (형식 주석) Type Safety (형식 안전성) Type Conversion (형 변환) Type Alias (타입 알리아스) Data Types with Memor..
Variables and Constants (변수와 상수) 코드를 작성할 때 변수(Variables)나 상수(Contants)를 사용하여 데이터를 저장할 수 있다. 변수는 계속 변하는 값이며, 상수는 한 번 지정하면 변하지 않는 값을 의미한다. Variables 변수 계속 변하는 값이면서, 그 값을 저장하는 공간 변수의 선언 및 사용 변수를 선언할 때는 var 키워드를 사용한다. var variableName = initialValue // var [변수명] : [데이터 타입] = [값] 사용 예시 // 선언 예시 var name = "bono" var age = 17 var temp = false // 값 변경 name = "spongebob" name = "patrick" age = 19 age = ..
주석 (comment) Single line comment 한 줄 주석을 달 수 있다. var str = "Hello, World" // var str = "Hello, World" Multi line comment 원하는 줄 사이로 주석을 달 수 있다. var str = "Hello, World" /* var str = "Hello, World" */ Inline comment 코드 사이에 주석을 달 수 있다. var str/* String */ = "Hello, World" 세미콜론 ; Swift에서는 세미콜론을 사용하지 않아도 된다. 다만, 여러 명령을 한줄에 쓸 때만 제한적으로 사용하기도 함. print 함수 - dump함수 print 함수 단순문자열 출력 dump 함수 단순문자열 출력 + 객체에..
- Total
- Today
- Yesterday
- 산술연산자
- RawValues
- variables
- 흐름제어구문
- Functions
- 옵셔널
- 훈련법
- continue
- 범위연산자
- Constants
- overflow
- 객체지향 생활체조
- 오토레이아웃
- playground
- scope
- 세자리수마다 콤마넣기
- 전산구문 기초용어
- 오버플로우연산자
- 결합성
- 구문이름표
- labeled
- 삼항연산자
- enumerations
- 반복문
- conditional
- 비트연산자
- datatypes
- swift
- optional
- iOS View Life Cycle
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |