SwiftUI / Day 1

Minsang Kang·2024년 2월 13일
0

100 Days of SwiftUI

목록 보기
2/4
post-thumbnail

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 : 변수
var greeting = "Hello, playground"

// var: Create a new variable
// greeting: Our variable's name
// = : Assign something
// "Hello, playground" : Initial value
  • let : 상수
let character = "Daphne"
  • print : 변수, 상수를 출력할 수 있음
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이 달라서 안됌)
  • 이를 통해 실수가 없도록 보장함
profile
 iOS Developer

0개의 댓글