[iOS]Protocol
iOS_Swift.zip 2022. 2. 20. 00:23

Protocol 🤷🏻‍♂️ https://docs.swift.org/swift-book/LanguageGuide/Protocols.html Protocols — The Swift Programming Language (Swift 5.6) Protocols A protocol defines a blueprint of methods, properties, and other requirements that suit a particular task or piece of functionality. The protocol can then be adopted by a class, structure, or enumeration to provide an actual implementation of tho docs.swi..

[iOS]옵저버 패턴(Observer Pattern)
iOS_Swift.zip 2022. 1. 5. 12:40

옵저버 패턴 ❓ 옵저버 패턴은 한 Object의 상태가 바뀌면 그 객체에 의존(구독) 하는 다른 객체들한테 연락이 가고 자동으로 내용이 갱신되는 방식으로 1:N(1대다) 관계를 정의합니다. 예시로 유튜브에서 구독자에게 알림 메시지를 보내는 것처럼 관찰 중인 객체에서 발생하는 이벤트를 여러 다른 객체에 알리는 메커니즘입니다. ⚠️ 용어 설명 Subject → 구독자(Concrete Observer)가 이벤트를 받을 주요 주제(Subject) 해당 Subject의 특정 이벤트 변경 시 구독하고 있는 구독자들이 해당 이벤트를 수신합니다. Observer → 구독자들의 부모가 되는 인터페이스 (Java에서는 추상 클래스) Concrete Observer → Observer 인터페이스를 상속받고, Subject에..