swift
-
UML Diagram with SwiftCS/ETC 2022. 9. 30. 18:09
UML Class Diagram UML 클래스 다이어그램은 객체 지향 시스템을 구성하고 시각화하는데 사용되는 그래픽적 표현이다. UML은 Unified Modeling Language의 약어로, UML의 클래스 다이어그램은 구조적인 다이어그램으로 다음의 시스템 요소들을 표현한다. 클래스 클래스의 속성 연산(메서드) 객체간의 관계 이름에서부터 알 수 있듯이 객체 지향 시스템의 핵심이 되는 객체를 생성하기 위한 '클래스'와 그들의 능력, 객체간의 관계를 시각적으로 표현한다. Class란 Class가 무엇인지 모르고 클래스 다이어그램을 그릴 수는 없다. 클래스는 객체를 찍어낼 수 있는 틀이 된다. 클래스와 객체는 서로를 빼놓고 얘기할 수 없다. 객체 지향 디자인의 핵심은 객체가 아닌 클래스에 관한 것인데, 이..
-
[Swift] Hashable 프로토콜Programming Language/Swift 2022. 7. 1. 16:42
개발하다보면 Hashable 프로토콜을 정말 많이 사용하게 된다. Hashable과 옵셔널 값을 같이 사용하면서 생긴 궁금증도 있고, Hashable을 굉장히 많이 사용하지만 깊이 알고 있지 않은 상태로 사용하고 있는 것 같아 Hashable 이 어떤 프로토콜인지 좀 더 자세히 공부해보려고 한다. Hashing Hasing(해싱)은 주어진 key나 문자열을 다른 값으로 변환시키는 작업이다. 해싱을 통해 고정 길이의 더 짧은 key, value로 표현되고, 이 key-value를 사용해서 원래의 값을 더 쉽고 빠르게 찾을 수 있다. 해싱은 데이터를 특정 정수 값으로 매핑하는 함수, 알고리즘을 사용한다. 즉 hash function을 사용해서 데이터에서 새로운 값을 만드는 것이다. 이 새로운 값을 hash ..
-
[Swift] 22. Generics - 제네릭Programming Language/Swift 2022. 6. 19. 09:14
Generics — The Swift Programming Language (Swift 5.7) Generics Generic code enables you to write flexible, reusable functions and types that can work with any type, subject to requirements that you define. You can write code that avoids duplication and expresses its intent in a clear, abstracted manner. Gener docs.swift.org Generic 코드는 어떤 타입에도 유연하게 대응할 수 있는 재사용 가능한 함수, 타입을 작성할 수 있게 해준다. 깔끔하고 추상화..
-
[Swift] 21. Extension - 익스텐션Programming Language/Swift 2022. 6. 19. 09:11
Extensions — The Swift Programming Language (Swift 5.7) Extensions Extensions add new functionality to an existing class, structure, enumeration, or protocol type. This includes the ability to extend types for which you don’t have access to the original source code (known as retroactive modeling). Extensions docs.swift.org Extension은 클래스, 구조체, 열거형, 프로토콜에 새로운 기능을 추가한다. 원래 소스 코드에 접근할 수 없을 때 타입을 확장..
-
[WWDC22] What's new in SwiftiOS 2022. 6. 13. 14:17
What's new in Swift - WWDC22 - Videos - Apple Developer Join us for an update on Swift. We'll take you through performance improvements, explore more secure and extensible Swift packages, and... developer.apple.com Swift Package Manager TOFU Trust On First Use. 패키지가 처음 다운로드 됐을 때 패키지의 지문을 기록하는 보안 프로토콜. 이후 다운로드 할 때마다 지문을 다시 확인해서 지문이 다를 경우 에러를 발생시킨다. Package plugins => Meet Swift Package plugins, C..
-
[Design Pattern] Singleton Pattern - 싱글턴 패턴CS/Design Pattern 2022. 6. 12. 17:16
Singleton Pattern은 세상에서 단 하나뿐인 특별한 객체를 만드는 디자인 패턴이다. 싱글턴 패턴이 무엇인지 알아보자. Singleton Pattern Singleton Pattern은 인스턴스가 하나 뿐인 객체를 만들게 하는 디자인 패턴이다. 인스턴스가 하나밖에 없기 때문에 클래스 다이어그램도 아래와 같이 클래스가 덩그러니 하나만 존재한다. 간단해 보이지만, 클래스의 인스턴스가 오로지 한 개만 존재할 수 있는 방법을 생각하면 그리 간단하지 않다. Why 인스턴스가 하나만 필요한 이유나 필요한 상황은 무엇일까? 객체가 하나만 있어도 될 때다. 스레드 풀, 캐시, 대화상자, 사용자 설정, 프린터 같은 디바이스를 위한 디바이스 드라이버는 하나만 존재해도 되거나, 하나만 존재해야하는 경우에 해당한다...
-
[Swift] 20. Protocol - 프로토콜Programming Language/Swift 2022. 6. 12. 09:51
Type Casting — The Swift Programming Language (Swift 5.7) Type Casting Type casting is a way to check the type of an instance, or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy. Type casting in Swift is implemented with the is and as operators. These tw docs.swift.org Protocol은 특정 기능을 할 수 있는 메서드, 프로퍼티, 요구사항의 청사진을 정의한다. 이 요구사항을 실제로 구현하기..
-
[Swift] 19. Type Casting - 타입 캐스팅Programming Language/Swift 2022. 6. 12. 09:44
Type Casting — The Swift Programming Language (Swift 5.7) Type Casting Type casting is a way to check the type of an instance, or to treat that instance as a different superclass or subclass from somewhere else in its own class hierarchy. Type casting in Swift is implemented with the is and as operators. These tw docs.swift.org 타입 캐스팅은 인스턴스의 타입을 확인하거나 다른 클래스의 인스턴스로서 다루기 위한 방법이다. Swift에서의 타입 캐스팅은..