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

IOS๐ŸŽ45

[Combine] Cancellable์ด๋ž€ element๋“ค์„ ๋ฐฉ์ถœํ•˜๋Š” ์ŠคํŠธ๋ฆผ์„ ๋‹ค ์‚ฌ์šฉํ–ˆ๋‹ค๋ฉด cancel() ํ•ด์ค˜์•ผ ์ž์›์ด dealloc ๋  ์ˆ˜ ์žˆ๋Š”๋ฐ์š”. ์ฆ‰ ์ด๋ฆ„ ๊ทธ๋Œ€๋กœ cancellation(์ทจ์†Œ)๋ฅผ ์œ„ํ•œ ํ”„๋กœํ† ์ฝœ์ž…๋‹ˆ๋‹ค. ๋งŒ์•ฝ cancel()์„ ํ˜ธ์ถœํ•˜์ง€ ์•Š์œผ๋ฉด ์–ด๋–ป๊ฒŒ ๋ ๊นŒ์š” ? viewController์˜ deinit()์ด ํ˜ธ์ถœ๋˜๊ณ  ๋‚˜๋„ ์ŠคํŠธ๋ฆผ์ด ์‚ด์•„์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๊ฐ’์„ ๋ฐฉ์ถœํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. deinit { print("ViewController deinit") } let publisher = [1, 2, 3].publisher publisher .map { $0 * 2 } .sink { value in print("\(value)") } //ViewController deinit //2 //4 //6 ์ŠคํŠธ๋ฆผ์ด ์‚ด์•„์žˆ๋‹ค๋ฉด Timer, network.. 2023. 4. 17.
[Combine] Scheduler๋ž€ ๋ฌด๋ ค 1๋…„๋งŒ์˜ combine ๊ธ€ ์ž‘์„ฑ.... ์ด๋‚ด์š”....ใ…Ž ์˜ค๋Š˜์€ ์ด๋Ÿฌ์ฟต ์ €๋Ÿฌ์ฟต ๊ณต๋ถ€๋ฅผ ํ•˜๋˜ ์™€์ค‘ combine์ด ๋จธ์˜€๋”๋ผ .. ใ…Ž ํ•˜๊ณ  ๋ณต์Šต์„ ํ•˜๊ฒŒ ๋˜์—ˆ๊ณ  Scheduler ์ •๋ฆฌ๋ฅผ ๋“œ๋””์–ด ํ•˜๋ ค๊ตฌ ํ•ฉ๋‹ˆ๋‹ค Scheduler closure์˜ ์‹คํ–‰ ์‹œ๊ธฐ์™€ ๋ฐฉ๋ฒ•์„ ์ •์˜ํ•˜๋Š” ํ”„๋กœํ† ์ฝœ ๊ทธ๋ ‡์Šต๋‹ˆ๋‹ค. scheduler๋„ ํ”„๋กœํ† ์ฝœ์ด๋„ค์š” ! protocol Scheduler ๊ณต์‹๋ฌธ์„œ Overview๋ฅผ ๋ณด๋ฉด You can use a scheduler to execute code as soon as possible, or after a future date. Individual scheduler implementations use whatever time-keeping system makes sense for them. S.. 2023. 4. 16.
[WWDC 2021] Meet AsyncSequence ํ•œ๋งˆ๋””๋กœ ์š”์•ฝํ•˜์ž๋ฉด sequence protocol์— async ๊ธฐ๋Šฅ์„ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•œ protocol async/ await ํ‚ค์›Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•ด ๋น„๋™๊ธฐ๋ฅผ ์ข€ ๋” ํŽธ๋ฆฌํ•˜๊ฒŒ ๋‹ค๋ฃจ๊ฒŒ ํ–ˆ๋Š”๋ฐ collection type์— ๋Œ€ํ•ด ์šฐ๋ฆฌ๋Š” for, while ๊ฐ™์€ sequence ๋ฃจํ”„๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•œ๋‹จ ๋ง์ด์ง€ ? ใ…‡ใ…‹ใ…‡ใ…‹ ์ด์— ๋Œ€ํ•œ async๋„ ๋งŒ๋“ค๊ฒ ์Œ ํ•ด์„œ ๋งŒ๋“ค์–ด์ง„ ํ”„๋กœํ† ์ฝœ --> AsyncSequence ์ฆ‰ sequence๋ฅผ ๋น„๋™๊ธฐ์ ์œผ๋กœ ๋งŒ๋“ค๊ฒ ๋‹ค๋Š” ๊ฒƒ๋งŒ ๋‹ค๋ฆ…๋‹ˆ๋‹ค ์„ธ์…˜์—์„œ๋„ sequence๋ฅผ ์•Œ๊ณ  ์žˆ๋‹ค๋ฉด ์ด๋ฏธ asynceSequence๋ฅผ ์•„๋Š”๊ฒƒ๊ณผ ๋‹ค๋ฆ„์ด ์—†๋‹ค๊ณ  ์–ธ๊ธ‰ํ•˜๊ณ  ์žˆ๋Š”๋ฐ์š” ์„ธ์…˜ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•ด๋ด…์‹œ๋‹ค. asyncSequence๋ฅผ ์‚ฌ์šฉํ•œ ์ฝ”๋“œ๋Š” ์œ„์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ์ฝ”๋“œ๋ฅผ ๋ณด๋ฉด ๋งŒ๋“ค์–ด์ง„ url์˜ lines์— ๋Œ€ํ•ด ์ฒซ๋ฒˆ์งธ ์ค„์„ .. 2022. 12. 18.
[WWDC 2021] Make blazing fast lists and collection views ์ „์— ์ •๋ฆฌํ•ด๋‘” ๊ธ€์ธ๋ฐ .. advances in collectionview layout์„ ๋ณด๊ธฐ ์ „์— ๊ฐœ์„ ๋œ collectionView lifecycle๋ฅผ ๋ณต์Šตํ•˜๊ณ ์ž ๊ธ€์„ ์“ฐ๊ฒŒ ๋˜์—ˆ๋‹ค. ์ด๋ฒˆ 2022 wwdc ๋ญ๊ฐ€ ๋‚˜์˜ฌ์ง€ ์ •๋ง ๊ถ๊ธˆํ•˜๋‹ค ..! https://developer.apple.com/videos/play/wwdc2021/10252/?time=1251 Make blazing fast lists and collection views - WWDC21 - Videos - Apple Developer Build consistently smooth scrolling list and collection views: Explore the lifecycle of a cell and learn how to appl.. 2022. 5. 27.
[WWDC 2021] Your guide to keyboard layout ์˜ค๋Š˜์€ keyboard์— ๊ด€ํ•œ ์˜์ƒ์„ ์‚ดํŽด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ์‚ฌ์‹ค ์ฒ˜์Œ ์˜์ƒ ์ œ๋ชฉ์„ ๋ณด์•˜์„๋•Œ ํ‚ค๋ณด๋“œ ?? ํ•˜ ๋ญ”๊ฐ€ ๋Œ๋ฆฐ๋‹ค .. ์‹ถ์—ˆ์Šต๋‹ˆ๋‹ค ใ…Žใ…Ž ์ฐฝ์—…ํŒ€์—์„œ ํ‚ค๋ณด๋“œ ์˜ฌ๋ฆฌ๊ณ , ๋‚ด๋ฆฌ๊ณ  ํ• ๋•Œ ๋ ˆ์ด์•„์›ƒ ๋ณ€๊ฒฝ ์ฝ”๋“œ๊ฐ€ ์ด๋ ‡๊ฒŒ ํ•˜๋Š”๊ฑฐ ๋งž๋‚˜ ..? ์•ผ๋งค ๊ฐ™์€๋ฐ ํ•˜๋Š” ์ฐœ์ฐœํ•จ์ด ์žˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ iOS 15์—์„œ ์–ด๋–ค ๋ณ€๊ฒฝ ์‚ฌํ•ญ์ด ์žˆ๋Š”์ง€ ์•Œ์•„๋ณด๊ณ ์ž ์˜์ƒ์„ ๋ณด๊ณ  ์ •๋ฆฌํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค !! https://developer.apple.com/videos/play/wwdc2021/10259/ Your guide to keyboard layout - WWDC21 - Videos - Apple Developer Discover how you can use the Keyboard Layout Guide to manage how keyboa.. 2022. 5. 26.
[WWDC 2021] Protect mutable state with Swift actors ์ด๋ฒˆ ์„ธ์…˜์—๋Š” await/async ์— ์ด์–ด ์ƒˆ๋กญ๊ฒŒ ๋“ฑ์žฅํ•œ Actor ํƒ€์ž…์— ๋Œ€ํ•ด ์ž์„ธํžˆ ์†Œ๊ฐœํ•ฉ๋‹ˆ๋‹ค !! https://developer.apple.com/videos/play/wwdc2021/10133/ Protect mutable state with Swift actors - WWDC21 - Videos - Apple Developer Data races occur when two separate threads concurrently access the same mutable state. They are trivial to construct, but are notoriously... developer.apple.com Actor in swift ์ฒซ๋ฒˆ์งธ๋กœ, actor๊ฐ€ ๋“ฑ์žฅํ•˜๊ฒŒ ๋œ ์ด์œ ์— ๋Œ€ํ•ด ์†Œ๊ฐœํ•ฉ๋‹ˆ.. 2022. 5. 24.
[WWDC 2021] Meet async/await in Swift What's new in Swift ์˜์ƒ์„ ๋ณด๋‹ค๊ฐ€ async/ await ๋ฌธ๋ฒ•์„ ์ƒˆ๋กญ๊ฒŒ ์†Œ๊ฐœํ•˜๋”๊ตฐ์š” ..! doc๋ฅผ ํ†ตํ•ด ๋จผ์ € ์ •๋ฆฌํ–ˆ๋˜ ์ ์ด ์žˆ๋Š”๋ฐ ์˜์ƒ์„ ๋ณด๋ฉด์„œ ๋ณต์Šตํ•˜๋Š” ๊ฒธ, ๋‹ค์‹œ ํ•œ๋ฒˆ ์ดํ•ด๊ฐ€ ์ž˜ ์•ˆ๊ฐ„ actor ๋ถ€๋ถ„์„ ๋‹ค์‹œ ๊ณต๋ถ€ํ•ด๋ณด๋ ค๊ตฌ ํ•ฉ๋‹ˆ๋‹ค !! ์•„๋ž˜ ๋น„๋””์˜ค์™€ doc๋ฅผ ๋ณด๋Š” ๊ฒƒ์„ ๊ฐ•๋ ฅํžˆ ์ถ”์ฒœ๋“œ๋ฆฝ๋‹ˆ๋‹ค์š” https://developer.apple.com/videos/play/wwdc2021/10132 Meet async/await in Swift - WWDC21 - Videos - Apple Developer Swift now supports asynchronous functions — a pattern commonly known as async/await. Discover how the new syn.. 2022. 5. 17.
[RxSwift] Transforming Operator (map, flatMap, scan, reduce) ์˜ค๋Š˜์€ observable ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€๊ณตํ•˜๋Š” operator์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. 1) Map Observerble์— ์˜ํ•ด ๋ฐฉ์ถœ๋˜๋Š” ์•„์ดํ…œ๋“ค์— ๋Œ€ํ•ด ๊ฐ๊ฐ ํ•จ์ˆ˜๋ฅผ ์ ์šฉํ•˜์—ฌ ๋ณ€ํ™˜ํ•ฉ๋‹ˆ๋‹ค. map์„ ์‚ฌ์šฉํ•˜๋Š” ์˜ˆ์‹œ์ž…๋‹ˆ๋‹ค. let ob = Observable.of("1", "2", "3", "4") ob.map { Int($0)! } .subscribe(onNext: { item in print(item) }).disposed(by: disposeBag) //์ถœ๋ ฅ //1 //2 //3 //4 stringํƒ€์ž…์˜ observable์„ map operator๋ฅผ ํ†ตํ•ด ๋ชจ๋“  item์„ Int ํƒ€์ž…์œผ๋กœ ์บ์ŠคํŒ… ํ•ด์ฃผ์—ˆ์Šต๋‹ˆ๋‹ค. 2) FlatMap flatMap์€ map๊ณผ๋Š” ๋‹ค๋ฅด๊ฒŒ ์ŠคํŠธ๋ฆผ์—์„œ ๋ฐฉ์ถœ๋˜๋Š” ์•„์ดํ…œ๋“ค์„ ๋‹ค๋ฅธ observ.. 2022. 5. 16.
[WWDC 2020] Advances in diffable data sources 2021 DiffableDataSource์˜ ๊ฐœ์„  ์‚ฌํ•ญ์„ ๋ณด๊ธฐ ์ „, ๊ด€๋ จ ์˜์ƒ์ด 2020๋…„๋„๊บผ๋„ ์žˆ๊ธธ๋ž˜ ๋จผ์ € ๋ณด๊ณ  ๊ฐ€์ž๋Š” ์ƒ๊ฐ์— ์ •๋ฆฌํ•˜๊ฒŒ ๋˜์—ˆ๋‹ค. https://developer.apple.com/videos/play/wwdc2020/10045 Advances in diffable data sources - WWDC20 - Videos - Apple Developer Diffable data sources dramatically simplify the work involved in managing and updating collection and table views to create dynamic and... developer.apple.com iOS 14๋ถ€ํ„ฐ Outline Style UI๊ฐ€ ์ถ”๊ฐ€๋˜์—ˆ์Šต.. 2022. 5. 12.
[WWDC 2019] Advances in UI Data Sources https://developer.apple.com/videos/play/wwdc2021/10252/ Make blazing fast lists and collection views - WWDC21 - Videos - Apple Developer Build consistently smooth scrolling list and collection views: Explore the lifecycle of a cell and learn how to apply that knowledge to... developer.apple.com ๋ฅผ ์ฝ๊ธฐ ์ „์— DiffableDataSource์— ๋Œ€ํ•ด ์ดํ•ดํ•˜๊ณ ์ž Advances in UI Data Sources๋ฅผ ๋จผ์ € ๋ณด๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ๊ณต๋ถ€ํ•ด๋ณด๊ณ  ์‹ถ์—ˆ๋˜ ๋‚ด์šฉ์ด๋ผ ์ญ‰ ํ๋ฆ„์„ ์ •๋ฆฌ.. 2022. 5. 10.
[RxSwift] Filtering Operator (distinctUntilChanged) DistinctUntilChanged ์—ฐ๋‹ฌ์•„ ๊ฐ™์€ ๊ฐ’์ด ์˜ค๋ฉด ์ƒ๋žตํ•œ๋‹ค. Observable.of(1, 2, 2, 1, 3) .distinctUntilChanged() .subscribe(onNext: { print($0) }) .disposed(by: disposeBag) /* Prints : 1 2 1 3 /* 2022. 5. 10.
[RxSwift] Error Handling Operator Network Error Handling์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋‹ค๊ฐ€ ๊ด€๋ จ operator๋“ค์„ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ตฌ ํ•ฉ๋‹ˆ๋‹ค. ์ฐธ๊ณ  : https://okanghoon.medium.com/rxswift-5-error-handling-example-9f15176d11fc RxSwift #5 — Error Handling & Example ์ด๋ฒˆ์—๋Š” RxSwift์—์„œ ์–ด๋–ป๊ฒŒ Error Handling ์„ ํ•˜๋Š”์ง€ ์•ฑ์—์„œ ํ”ํžˆ ๋ฐœ์ƒํ•˜๋Š” ์—๋Ÿฌ ์˜ˆ์ œ๋“ค์„ ํ†ตํ•ด ์•Œ์•„๋ณด๋ ค๊ณ  ํ•œ๋‹ค. okanghoon.medium.com RxSwift์—์„œ๋Š” Error Handling์„ ํ•˜๋Š”๋ฐ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ๋ฐฉ๋ฒ•์ด ์žˆ์Šต๋‹ˆ๋‹ค. 1. Catch ํŠน์ • ๊ฐ’์œผ๋กœ error ๋ณต๊ตฌ 2. Retry ์žฌ์‹œ๋„ 3. materialize / dematerialize : Sequence.. 2022. 5. 10.
[์•„ํ‚คํ…์ณ] RIBs๋ž€ RIBs๋ž€ ์šฐ๋ฒ„์—์„œ ๋งŒ๋“  ์•„ํ‚คํ…์ณ์ž…๋‹ˆ๋‹ค. ์‚ฌ์‹ค ์ž‘๋…„์— ํŠœํ† ๋ฆฌ์–ผ 1์„ ์กฐ๊ธˆ ๋”ฐ๋ผํ•ด๋ณด๊ธดํ–ˆ๋Š”๋ฐ .. ๋˜๊ฒŒ ๋ณต์žก๋ณต์žกํ–ˆ๋˜ ๊ธฐ์–ต๋งŒ ๋‚จ์•„์žˆ๋Š”๊ฑฐ ๊ฐ™์•„์š” ... ๊ทธ๋ž˜์„œ RIBs๋ฅผ ์ด๋ฃจ๋Š” ๊ธฐ๋ณธ ๊ฐœ๋…์— ๋Œ€ํ•ด ํŠœํ† ๋ฆฌ์–ผ2๊นŒ์ง€ ๋ณด์•˜๊ฒ ๋‹ค ๋‹ค์‹œํ•œ๋ฒˆ ์ •๋ฆฌ ํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค ์ด๋ฒˆ์— ํ”„๋กœ์ ํŠธ๋•Œ ๊ผญ ์ ์šฉํ•ด๋ณด๋ ค๊ตฌ์š” !! What are RIBs For? RIBs๋Š” ์šฐ๋ฒ„์˜ ํฌ๋กœ์Šค ํ”Œ๋žซํผ ์•„ํ‚คํ…์ณ ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. RIBs๋Š” ๋งŽ์ด ์–ฝํ˜€์žˆ๋Š” state๋ฅผ ํฌํ•จํ•˜๊ณ  ์žˆ๋Š” ํฐ ๋ชจ๋ฐ”์ผ ์•ฑ์„ ์œ„ํ•ด ๋””์ž์ธ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฒ„๋ฅผ ์œ„ํ•œ ์ด ํ”„๋ ˆ์ž„์›Œํฌ๋ฅผ ๋””์ž์ธ ํ• ๋•Œ ์•„๋ฆฌ ์›์น™์„ ์ค€์ˆ˜ํ•˜๊ณ ์ž ํ•˜์˜€์Šต๋‹ˆ๋‹ค. Encourage Cross-Platform Collaboration : ์šฐ๋ฆฌ ์•ฑ์˜ ๋ณต์žกํ•œ ๋ถ€๋ถ„์€ ๋Œ€๋ถ€๋ถ„ iOS์™€ Android์—์„œ ๋น„์Šทํ•ฉ๋‹ˆ๋‹ค. RIBs๋Š” Androi.. 2022. 5. 6.
[Combine] ConnectablePublisher ConnectablePublisher connecting, canceling์˜ ๋ช…์‹œ์ ์ธ ์˜๋ฏธ๋ฅผ ๊ฐ€์ง„ publisher subject์™€ ๊ฐ™์ด publisher์˜ ์ผ๋ถ€์ž…๋‹ˆ๋‹ค. element๋ฅผ ์ƒ์‚ฐํ•˜๊ธฐ ์ „ ์ถ”๊ฐ€์ ์ธ configuration, setup์„ ์ˆ˜ํ–‰ํ•  ํ•„์š”๊ฐ€ ์žˆ์„๋•Œ, ConnectablePublisher๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. connect() ๋ฉ”์†Œ๋“œ ํ˜ธ์ถœ ์ „, publisher๋Š” ์–ด๋–ค element๋„ ์ƒ์‚ฐํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. makeConnectable()์„ ์‚ฌ์šฉํ•˜์—ฌ ConnectablePublisher์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. private func connectablePublisher(){ let publisher = ["hi", "hello"].publisher.makeConnectable() let cancellab.. 2022. 5. 3.
[RxSwift] Schedular๋ž€ (subscribeOn, observeOn) ์ด๋ฆ„์€ ์กฐ๊ธˆ ๋‹ค๋ฅด์ง€๋งŒ ์–ด๋Š ๊ณณ์—์„œ ์ž‘์—… ํ• ์ง€(main, global) ์‹คํ–‰ ํ๋ฆ„์˜ ์œ„์น˜๋ฅผ ์ง€์ •ํ•ด์ฃผ๋Š” ๊ฒƒ์„ ๋งํ•ฉ๋‹ˆ๋‹ค. ๊ธฐ๋ณธ swift์—์„œ๋Š” thread ์ž‘์—…์„ ๋น„๋™๊ธฐ์ ์œผ๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•ด GCD๋ฅผ ์‚ฌ์šฉํ–ˆ์—ˆ์Šต๋‹ˆ๋‹ค. RxSwift์—์„œ GCD์— ๋Œ€์‘๋˜๋Š” ๊ฐœ๋…์ด Schedular๋ผ๊ณ  ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Schedular๋ฅผ ํ†ตํ•ด Observable์„ ์–ด๋””์„œ ์ƒ์„ฑํ• ์ง€, Observer๊ฐ€ ์–ด๋””์„œ ๊ด€์ฐฐํ• ์ง€ ์ง€์ •ํ•ด ์ค„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. observeOn ๊ณผ subscribeOn์€ ์Šค์ผ€์ค„๋Ÿฌ๋กœ ์ž‘๋™๋˜๋Š” ๋Œ€ํ‘œ์ ์ธ ๋‘ ์—ฐ์‚ฐ์ž์ž…๋‹ˆ๋‹ค. observeOn๊ณผ subscribeOn ๋‘˜์˜ ์ฐจ์ด๋ฅผ ๋ช…ํ™•ํ•˜๊ฒŒ ๊ตฌ๋ถ„ํ•˜๋Š”๋ฐ ์žˆ์–ด http://rx-marin.com/post/observeon-vs-subscribeon/ observeOn vs. subscr.. 2022. 4. 29.
[์•„ํ‚คํ…์ณ] ReactorKit์ด๋ž€ ๋ฐฐ์šธ๊ฒŒ ์ •๋ง ๋งŽ๋‹ค ..! ํ•˜๋‚˜ ํ•˜๋‚˜ ์•„ํ‚คํ…์ณ๋“ค์„ ์•Œ์•„๊ฐ€๋ฉด์„œ MVx ์™ธ์˜ ์•ฑ ์•„ํ‚คํ…์ณ ๊ฐœ๋…์ด ์ ์  ๊ตฌ์ฒดํ™”๋˜๋Š”๊ฑฐ ๊ฐ™๋‹ค. ์ด๋ฒˆ์—๋Š” reactorKit ๋„ํ๋จผํŠธ๋ฅผ ์ฝ์–ด๋ณด๊ณ  ๋‹ค๋ฅธ ์•„ํ‚คํ…์ณ์™€ ์–ด๋–ป๊ฒŒ ๋‹ค๋ฅธ์ง€ ์•Œ์•„๋ณด๋ ค๊ตฌ ํ•œ๋‹ค !! ์ฐธ๊ณ  : https://github.com/ReactorKit/ReactorKit GitHub - ReactorKit/ReactorKit: A library for reactive and unidirectional Swift applications A library for reactive and unidirectional Swift applications - GitHub - ReactorKit/ReactorKit: A library for reactive and unidirectional S.. 2022. 4. 24.
[Swift] Optional์— ๋Œ€ํ•œ ๊ณ ์ฐฐ Swift๋Š” ์•ˆ์ „์„ฑ์„ ์ค‘์š”ํ•œ ์š”์†Œ ์ค‘ ํ•˜๋‚˜๋ผ๊ณ  ์ƒ๊ฐํ•˜๋Š” ์–ธ์–ด์ž…๋‹ˆ๋‹ค. ๊ทธ ๋ฐ”ํƒ•์ด ๋˜๋Š” ๋ฌธ๋ฒ• ์ค‘ ํ•˜๋‚˜๊ฐ€ ๋ฐ”๋กœ ์˜ต์…”๋„(Optional)์ž…๋‹ˆ๋‹ค. ์ฒ˜์Œ ์˜ต์…”๋„์„ ๋ดค์„๋•Œ ๋‹ค๋ฅธ ์–ธ์–ด์—์„œ๋Š” ์ฐพ์•„๋ณผ ์ˆ˜ ์—†๋Š” Swift๋งŒ์˜ ๋…ํŠนํ•œ ๋ฌธ๋ฒ•์ด๋ผ๊ณ  ์ƒ๊ฐ ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. ์–ผ๋งˆ์ „ ์˜ต์…”๋„์„ ๋žฉํ•‘ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ ์ด๋Ÿฐ ๋žฉํ•‘ํ•˜๋Š” ๋ฐฉ์‹์ด ๊ท€์ฐฎ์„ ๋ฒ•(?)๋„ ํ•œ๋ฐ ์™œ ์˜ต์…”๋„์„ ์‚ฌ์šฉํ•˜๋Š”์ง€์— ๋Œ€ํ•œ ์งˆ๋ฌธ์„ ๋ฐ›์•˜์Šต๋‹ˆ๋‹ค. ์˜ต์…”๋„์€ ์˜ต์…”๋„์ด์ง€ ์™œ ์‚ฌ์šฉํ•˜๋Š”์ง€ ์ƒ๊ฐํ•ด๋ณธ์ ์ด ์—†์–ด์„œ nil๊ฐ’์ผ ๊ฒฝ์šฐ ๋ฉ”๋ชจ๋ฆฌ์— ์˜ฌ๋ผ๊ฐ€์ง€ ์•Š๋Š”๋‹ค๋ผ๋Š” ์—‰๋šฑํ•œ ๋Œ€๋‹ต์„ ํ•œ๊ฒŒ ์ฐธ ์•„์‰ฝ๋”๋ผ๊ตฌ์š” ..(nil๋„ ๋ฉ”๋ชจ๋ฆฌ์—์„œ ๋‹ค๋ฅธ ๊ฐ’๋“ค๊ณผ ๊ฐ™์ด ๊ฐ’์„ ๊ฐ€์ง„๋‹ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค ํ•˜ํ•˜) ๊ทธ๋Ÿฌ๋˜ ์ค‘ ์˜ต์…”๋„์— ๋Œ€ํ•ด ์ข‹์€ ๊ธ€์„ ์ฝ๊ฒŒ ๋˜์–ด ๋ฉด์ ‘๋•Œ ๋งˆ์ € ๋ชปํ•œ ์ƒ๊ฐ๊ณผ ๊ทธ ๋Œ€๋‹ต์„ ๋‹ค์‹œ ํ•ด๋ณด๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค !! Optional์ด๋ž€ ? ๊ฐ’์ด .. 2022. 4. 23.
[Combine] Subject๋ž€ (AnyPublisher) ์ •์˜ : publisher, subscriber์™€ ๊ฐ™์ด ํ”„๋กœํ† ์ฝœ์ด๋„ค์š” ! ๊ทธ๋ฆฌ๊ณ  subject๋Š” ์‚ฌ์‹ค publisher๋ž๋‹ˆ๋‹ค. subject๋Š” Publisher ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  send() ๋ฉ”์†Œ๋“œ๋ฅผ ํ†ตํ•ด ๊ฐ’์„ ์ฃผ์ž…ํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰ publisher๋Š” ๊ฐ’์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ์ฃผ์ฒด์˜€๋‹ค๋ฉด ์ด ๊ฐ’์— ๋‹ค๋ฅธ ๊ฐ’์„ ์ฃผ์ž…ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด ๋ฐ”๋กœ subject์ž…๋‹ˆ๋‹ค. subject๋Š” ๋‹ค์Œ๊ณผ ๊ฐ™์ด ๋‘๊ฐ€์ง€ ํด๋ž˜์Šค๋กœ ๊ตฌํ˜„๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. PassthroughSubject CurrentValueSubject PassthroughSubject downstream ๊ตฌ๋…์ž๋“ค์—๊ฒŒ ์š”์†Œ๋ฅผ ๋ฐฉ์ถœํ•˜๋Š” broadcast ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ์‹œ๋ฅผ ๋ด…์‹œ๋‹ค. PassthroughSubject๋ฅผ ๋งŒ๋“ค์–ด subscriber1๊ณผ subscriber2๋ฅผ.. 2022. 4. 17.
[Combine] Combine, Publisher, Subscriber ์— ๋Œ€ํ•ด์„œ ์˜ค๋Š˜์€ Apple ์—์„œ ๋งŒ๋“  Reactive ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ•œ ํ”„๋ ˆ์ž„ ์›Œํฌ "Combine"์— ๋Œ€ํ•ด ์ •๋ฆฌ ํ•ด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณค WWDC2021์—์„œ ์ƒˆ๋กœ ๋‚˜์˜จ Concurrency์— ๋Œ€ํ•ด์„œ๋„ ์•Œ์•„๋ณผ ์˜ˆ์ •์ž…๋‹ˆ๋‹ค. โžก๏ธ ์˜ค๋Š˜์˜ ๋ชฉํ‘œ : Combine, Publisher, Subscriber, Publisher ↔๏ธ Subscriber ์ •์˜ : ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ ์—ฐ์‚ฐ์ž๋“ค์„ ํ†ตํ•ด ๋น„๋™๊ธฐ ์ด๋ฒคํŠธ๋“ค์„ ํ•ธ๋“ค๋ง ํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ Combine ํ”„๋ ˆ์ž„์›Œํฌ๋Š” ์‹œ๊ฐ„์ด ํ๋ฆ„์— ๋”ฐ๋ฅธ ๊ฐ’ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ์„ ์–ธ์  Swift API๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ฐ’์€ ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ ๋น„๋™๊ธฐ ์ด๋ฒคํŠธ๋ฅผ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Combine์€ ์‹œ๊ฐ„์ด ์ง€๋‚จ์— ๋”ฐ๋ผ ๋ณ€๊ฒฝ๋  ์ˆ˜ ์žˆ๋Š” ๊ฐ’์„ ๋…ธ์ถœํ•˜๋Š” Publisher์™€ Publisher๋กœ๋ถ€ํ„ฐ ํ•ด๋‹น ๊ฐ’์„ .. 2022. 4. 17.
[WWDC 2021] ARC in Swift: Basics and beyond (ARC ์ตœ์ ํ™”) ์˜์ƒ : https://developer.apple.com/videos/play/wwdc2021/10216/ ARC in Swift: Basics and beyond - WWDC21 - Videos - Apple Developer Learn about the basics of object lifetimes and ARC in Swift. Dive deep into what language features make object lifetimes observable,... developer.apple.com Object lifetimes and ARC traveler1์˜ ๋งˆ์ง€๋ง‰ ์‚ฌ์šฉ ํ›„์— release operation์„ ์ˆ˜ํ–‰ traveler1์˜ Retain operation์€ ์ˆ˜ํ–‰๋˜์ง€ ์•Š๋Š”๋ฐ ์™œ๋ƒํ•˜๋ฉด ์ดˆ๊ธฐ.. 2022. 4. 16.