swift공식문서 3

[Swift] 공식 문서 요약 - The Basics_04

본 내용은 Swift 공식 문서에 기반하여 작성되었습니다. https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html Error Handling 프로그램 실행 시 혹시나 발생할 수 있는 에러에 대한 처리 func canThrowAnError() throws { // this fuction may or may not throw an error } // 이 함수는 아래와 같이 do-try-catch 를 통해 사용하면 특정 Error에 대해 처리할 수 있다. do { try canThrowAnError() // no error was thrown } catch { // an error was thrown } [예시] func makeASandwich() t..

DEVELOPMENT/iOS AOS 2023.09.13

[Swift] 공식 문서 요약 - The Basics_03

본 내용은 Swift 공식 문서에 기반하여 작성되었습니다. https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html Optional [옵셔널] '값이 없을 수 있는 상황'에서 사용. let possibleNumber = "123" let convertedNumber = Int(possibleNumber) // "123"은 Int로 변경 가능하나 "Hello, World"의 경우 Int로 변경 불가능 // 즉, 모든 String을 Int로 변경 가능하지 않음 -> return optional Int nil [닐] optional 변수에서 값이 없을 때를 표현 var serverResponseCode: Int? = 404 // serverResponse..

DEVELOPMENT/iOS AOS 2023.09.13

[Swift] 공식 문서 요약 - The Basics_02

본 내용은 Swift 공식 문서에 기반하여 작성되었습니다. https://docs.swift.org/swift-book/LanguageGuide/TheBasics.html Integers [정수] 부분 표현이 아닌 수. 부호가 있거나 (양수, 0, 음수) 없는(양수, 0) 수를 포함 // 부호가 없는 정수 유형 : 8-bit , 부호가 있는 정수 유형 : 32-bit // 각 유형에 별도의 이름이 존재한다 (Int8, Int32 등) let minValue = UInt8.min // minValue is equal to 0, and is of type UInt8 let maxValue = UInt8.max // maxValue is equal to 255, and is of type UInt8 // 각 ..

DEVELOPMENT/iOS AOS 2023.09.13