https://www.hackingwithswift.com/100/swiftui/1
Why Swift?
https://www.youtube.com/watch?v=ug6T-iFk5OY
- 2014에 시작된 언어
- 새로운 기술을 활용하는 언어
- 2019년에 SwiftUI 프레임워크가 등장
About this course
https://www.youtube.com/watch?v=GG7bu0NRyYM
How to follow along
https://www.youtube.com/watch?v=S6udZCgHiLA
- Xcode 설치하세여
- Playground도 있어여
How to create variables and constants
https://www.youtube.com/watch?v=jlkcxTyM8m4
var greeting = "Hello, playground"
let character = "Daphne"
let playerName = "Roy"
print(playerName)
- camel case : 변수, 상수명의 "규칙"
- 소문자로 시작, 새 단어를 입력할 때 큰 문자로 이어서 작성
- 가능하다면 let을 사용하여 코드를 더 최적화, 실수로 값이 변경되는 것을 방지
How to create strings
https://www.youtube.com/watch?v=jfBcryGKf38
- """ 를 사용하여 문자열 개행을 넣을 수 있음, 마지막 """는 단독으로 마지막줄에 있어야 함
- .count : 문자개수를 알 수 있음
- .uppercased() : 대문자 문자열을 반환
- .hasPrefix : 특정 문자열로 시작하는지 여부값 반환
- .hasSuffix : 특정 문자열로 끝나는지 여부값 반환
How to store whole numbers
https://www.youtube.com/watch?v=kVLntzY4YQg
- 큰 숫자를 를 포함하여 값을 설정해도 가능, Swift 언어는 해당 를 무시
- -, +, *, /
- +=, *=, -=, /=
- .isMultiple(of: Int) 함수를 통해 배수인지 여부값 반환
How to store decimal numbers
https://www.youtube.com/watch?v=JGslWiKS_CU
- 소수는 기본적으로 Double 타입
- 1.0 + 2.0은 3.0과 같지 않음 (오차가 존재)
- Int형 + Double형 계산 불가, 이를 type safety 라고 부름
- 즉, Swift 언어는 type-safe 언어임
- int형 변수를 선언한 후 문자열로 값을 변경할 수 없음 (type이 달라서 안됌)
- 이를 통해 실수가 없도록 보장함