๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

SwiftUI2

[SwiftUI] Service Layer to ViewModel with Combine ์ฐธ๊ณ  ๋ฐ ์ถœ์ฒ˜ ์‚ฌ์ดํŠธ https://www.youtube.com/watch?v=TlJUMVKtUhc&list=PLwvDm4Vfkdphbc3bgy_LpLRQ9DDfFGcFu&index=7 Service layer์˜ ์—ญํ™œ - ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค๋ฅผ ๋‹ค๋ฃจ๋Š” ๋ชจ๋“  ๋กœ์ง์„ ํฌํ•จํ•œ ๋„คํŠธ์›Œํฌ ๋ ˆ์ด์–ด - ๋ฐ์ดํ„ฐ๋ฅผ ๋””์ฝ”๋”ฉ ํ•˜๊ณ  ๋ทฐ ๋ชจ๋ธ๋กœ ์ „๋‹ฌํ•˜๋Š” ์—ญํ™œ์„ ํ•จ Services ์ƒ์„ฑ - New file > Swift ํŒŒ์ผ ์„ ํƒ ํ›„ PrefixDataService.swift ํŒŒ์ผ ์ƒ์„ฑ Published ๋ณ€์ˆ˜ ์„ ์–ธ @Published var allCoins: [CoinModel] = [] - @Published ํ”„๋กœํผํ‹ฐ ๋žฉํผ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ํผ๋ธ”๋ฆฌ์…”๋ฅผ ์ƒ์„ฑํ•จ - subscriber๊ฐ€ ํผ๋ธ”๋ฆฌ์…”๋กœ ์„ ์–ธ๋œ ๋ณ€์ˆ˜๋ฅผ ๊ตฌ๋…ํ•  ์ˆ˜ ์žˆ์Œ Cancellab.. 2022. 11. 21.
[SwiftUI 3.0] URLSession ๊ณผ List, @Published, @ObservedObject ์‚ฌ์šฉํ•˜๊ธฐ SwiftUI ์—์„œ๋Š” ๋ทฐ์—์„œ ์‚ฌ์šฉํ•  ๊ฐ’์„ ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹์ด ๊ธฐ์กด Storyboard ๋ฐฉ์‹๊ณผ๋Š” ๋‹ค๋ฆ…๋‹ˆ๋‹ค. ์˜ค๋Š˜์€ ๋ทฐ ๋ฐ–์˜ ํด๋ž˜์Šค์—์„œ ์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ ํ”„๋กœํผํ‹ฐ์›Œ๋ ˆํผ ์ธ @ObservedObject๋ฅผ ์†Œ๊ฐœํ•˜๊ณ  ์•„์ฃผ ๊ฐ„๋‹จํ•œ ํŠœํ† ๋ฆฌ์–ผ๋กœ ์‚ฌ์šฉ๋ฒ•์„ ์ •๋ฆฌํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค @ObservedObject๋ฅผ ์•Œ๊ธฐ ์ „์— ObservableObject์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณผ๊ฒŒ์š” ObservableObject๋Š” Combine์— ์†ํ•œ ํ”„๋กœํ† ์ฝœ์ž…๋‹ˆ๋‹ค ํ•ด๋‹น ํฌ์ŠคํŒ…์—์„œ Combine์„ ๋‹ค๋ฃจ์ง€ ์•Š์ง€๋งŒ RxSwift์˜ ๊ธฐ๋Šฅ์ด๋ผ๊ณ  ์ƒ๊ฐํ•˜์‹œ๋ฉด ๋˜์š” @ObservedObject๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ ObservableObject ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•ด ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. @ObservedObject๋Š” ํ•ด๋‹น ํ”„๋กœํผํ‹ฐ์˜ ๊ฐ’์ด ๋ณ€๊ฒฝ๋˜๋ฉด @Published ํ”„๋กœํผํ‹ฐ ์›Œ๋ ˆํผ๊ฐ€ ์ž๋™์œผ๋กœ.. 2021. 10. 27.