본문 바로가기

Swift24

[Swift] Initialization References https://docs.swift.org/swift-book/LanguageGuide/Initialization.html Contents Setting Initial Values for Stored Properties Customizing Initialization Default Initializers Initializer Delegation for Value Types Class Inheritance and Initialization Failable Initializers Required Initializers Setting a Default Property Value with a Closure or Function Initialization(초기화)는 클래스, 구조체, 열거형의 인.. 2022. 1. 3.
[Swift] Inheritance (상속) References https://docs.swift.org/swift-book/LanguageGuide/Inheritance.html Contents Defining a Base Class Subclassing Overriding Preventing Overrides 클래스는 다른 클래스로부터 메소드(methods), 속성(propertites), 그리고 다른 특징들을 상속(inherit)받을 수 있습니다. 다른 클래스로부터 상속을 받을 때, 상속을 받는 클래스는 subclass라고 하고, 상속을 하는 클래스는 superclass라고 합니다. Swift의 클래스는 그 클래스의 superclass에 속하는 메소드, 속성, 서브스크립트를 호출하거나 액세스할 수 있고, 메소드, 속성, 서브스크립트의 오버라이.. 2021. 12. 30.
[Swift] Subscripts (서브스크립트) References https://docs.swift.org/swift-book/LanguageGuide/Subscripts.html Contents Subscript Syntax Subscript Usage Subscript Options Type Subscripts 클래스, 구조체, 열거형은 subscripts(서브스크립트)를 정의할 수 있는데, 서브스크립트는 콜렉션(collection), 리스트, 시퀀스의 멤버 요소에 접근할 수 있는 shortcut 입니다. 서브스크립트를 사용하면 다른 메소드없이 인덱스를 사용하여 값을 설정하고 검색할 수 있습니다. 예를 들어, 배열 인스턴스의 요소는 someArray[index]로 액세스하고 딕셔너리의 요소는 someDictionary[key]로 액세스할 수 있습.. 2021. 12. 30.
[Swift] Methods References https://docs.swift.org/swift-book/LanguageGuide/Methods.html Contents Instance Methods mutating Type Methods 메소드(methods)는 특정한 타입과 연관된 함수입니다. 클래스, 구조체, 열거형은 인스턴스 메소드(instance methods)를 정의할 수 있는데, 이는 주어진 타입의 인스턴스에서 특정한 태스크나 기능을 수행합니다. 또한, 타입 메소드(type methods)를 정의할 수 있는데, 이는 타입 그자체와 연관되어 있습니다. Instance Methods 인스턴스 메소드는 특정 클래스, 구조체, 열거형의 인스턴스에 종속된 함수입니다. 이 메소드들은 그 인스턴스들의 기능을 서포트하는데, 인스턴.. 2021. 12. 26.
[Swift] Properties References https://docs.swift.org/swift-book/LanguageGuide/Properties.html Contents Stored Properties Computed Properties Property Observers Property Wrappers Global and Local Variables Type Properties [Swift] Structures and Classes (구조체와 클래스) 구조체 및 클래스에 이어서 속성에 대해 알아보겠습니다. 속성(프로퍼티, properies)는 특정 클래스, 구조체 또는 열거형과 연관된 값입니다. 속성의 종류에는 여러가지가 있는데, 저장 속성(Stored properties)는 인스턴스의 일부로 상수나 변수 값을 저장하는 것.. 2021. 12. 25.
[Swift] Structures and Classes (구조체와 클래스) References https://docs.swift.org/swift-book/LanguageGuide/ClassesAndStructures.html Contents 구조체와 클래스 비교 Structures and Enumerations are Value Types Class are Reference Types 구조체(Structures)와 클래스(Classes)는 범용적(general-purpose)이고 유연한 구성 요소입니다. 상수나 변수, 함수를 정의하는 문법을 동일하게 사용하여 속성(프로퍼티, property)와 메소드(method)를 정의하여 구조체나 클래스에 기능을 추가할 수 있습니다. 다른 프로그래밍 언어와 달리 Swift는 커스텀 구조체나 클래스를 위해 인터페이스와 구현 파일을 분리하여 .. 2021. 12. 24.
[Swift] Enumerations (열거형, 열거자) References https://docs.swift.org/swift-book/LanguageGuide/Enumerations.html Contents Enumeration Syntax Maching Enumeration Values with a Switch Statement Iterating over Enumeration Cases Associated Values Raw Values Recursive Enumerations Enumeration(열거형)은 관련된 값들의 그룹에 대한 공통적인 유형을 정의하고 코드 내에서 type-safe한 방식으로 해당 값으로 작업할 수 있도록 합니다. C에 익숙하다면 C 열거형이 정수 값들의 집합에 이름을 할당한다는 것을 알고 있습니다. Swift의 열거형은 훨씬 더.. 2021. 12. 22.
[Swift] Closures (클로저) References https://docs.swift.org/swift-book/LanguageGuide/Closures.html Contents Closures Closure Expressions Trailing Closures Capturing Values Closures Are Reference Types Escaping Closures Autoclosures 클로저(Closures)가 꽤 익숙하지는 않아서, 다른 부분을 먼저 보고 공부를 해보려고 했습니다만.. 일단 그냥 진행해보기로 했습니다. 조금 내용이 부족할 수도 있습니다.. ! 클로저는 Swift에서만 사용되는 개념은 아니고, 함수형 프로그래밍 언어에서 나타나는 중요한 특성이라고 합니다. Swift의 클로저는 C나 Objective-C의 블.. 2021. 12. 22.
[Swift] Functions (함수) References https://docs.swift.org/swift-book/LanguageGuide/Functions.html Contents Defining and Calling Functions Function Parameters and Return Values Function Argument Labels and Parameter Name Function Types Nested Functions Functions(함수)는 특정 작업을 수행하는 코드 덩어리입니다. 함수가 수행하는 작업을 식별하는 이름을 지정하고, 해당 작업을 수행할 때 함수 이름을 호출(call)하여 사용합니다. Swift의 통합 함수 문법은 유연해서 매개변수 이름이 없는 단순한 C 스타일의 함수부터 Objective-C 스타일 .. 2021. 12. 18.
[Swift] Control Flow (제어문) Referneces https://docs.swift.org/swift-book/LanguageGuide/ControlFlow.html Contents For-In Loops While (while, repeat-while) Conditional Statements (if, switch) Control Transfer Statements (continue, break, fallthrough, labeled statements) Early Exit (guard) Checking API Availability Swift에서는 while 루프, if, guard, switch 그리고 break와 continue 등의 다양한 제어문을 지원합니다. 하나씩 알아보도록 하겠습니다. For-In Loops 배열의 항목.. 2021. 12. 16.