Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- 스위프트
- dispatchqueue
- swift concurrency
- SwiftUI
- widgetkit
- 스유
- 대외활동
- uikit
- Swift
- cs
- 백준
- 영남대
- 1일1알골
- 문법
- 리액트
- widget
- 웹
- 네트워크
- 컴퓨터그래픽스
- c++
- spritekit
- 멋사
- 후기
- 알고리즘
- 위젯킷
- 운영체제
- composable architecture
- TCA
- 멋쟁이사자처럼
- Protocol
Archives
- Today
- Total
목록associatedtype (1)
맛동산이
Swift) Associated type
associated type은 프로토콜에서 많이 보긴했는데 명확하게 이해가 안가서 한번더 정리한다. Generic 지네릭은 범용타입 T를 사용해서 컴파일 시점에 타입을 지정해주는 것을 의미한다. 지네릭을 사용하면, 하나의 코드에 유연하게 코드 중복을 피해서 다양한 타입을 삽입하여 사용할수 있게 된다. struct State { func plus(value: T) func minus(value: T) } 이런식으로 사용하게 된다. 하지만 이것을 프로토콜로 사용할때 동일하게 명시해줘야하는것을 associated type으로 작성을 대신한다. protocol protocol State { associatedtype typeA func plus(value: typeA) func minus(value: typeA..
앱/Swift
2024. 1. 1. 21:24