반응형
SwiftUI의 View 및 ViewModel 관계에서 주로 쓰는게 @Published와 @ObservedObject인데요
Class FooView {
@ObservedObject viewModel = FooViewModel()
}
Class FooViewModel: ObservableObject {
@Publihsed foo: String
}
이들 관계 및 사용 관련해서 이해하기 좋은 블로그를 하나 소개하려 합니다.
https://pilgwon.github.io/post/published-risks-and-usage-explained
[수위프트UI/번역] 코드로 알아보는 @Published의 사용법과 위험성
@Published risks and usage explained with code examples
pilgwon.github.io
https://www.avanderlee.com/swiftui/published-property-wrapper/
@Published risks and usage explained with code examples
Learn how to use the @Published property wrapper and prevent yourself from running into common bugs when using it in the wrong way.
www.avanderlee.com
반응형
'Programming > Swift' 카테고리의 다른 글
[WWDC2021] Your guide to keyboard layout (0) | 2022.12.14 |
---|---|
withCheckedContinuation memory leak 현상 및 해결방법 (0) | 2022.11.21 |
[SwiftUI] VStack과 LazyVStack과의 차이 (0) | 2022.09.23 |
[SwiftUI] @FocusState Property Wrapper (0) | 2022.09.19 |
realm swift 강의 (0) | 2022.08.16 |