Swift 47

[ Swift ] Swift๋ž€?

Swift Swift is a general-purpose programming language that's approachable for newcomers and powerful for experts. It is fast, modern, safe, and a joy to write.์œ„ ๊ธ€์€ Swift.org์—์„œ ๊ฐ€์žฅ ๋จผ์ € ๋ณผ ์ˆ˜ ์žˆ๋Š” Swift ์†Œ๊ฐœ๊ธ€์ด๋‹ค. Swift๋Š” ์ ‘๊ทผ์„ฑ์ด ์ข‹๊ณ  ๊ฐ•๋ ฅํ•œ ๋ฒ”์šฉ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ด๋ฉฐ, ๋น ๋ฅด๋ฉฐ ํ˜„๋Œ€์ ์ด๊ณ  ์•ˆ์ „ํ•˜์—ฌ ์ฆ๊ฒ๊ฒŒ ํ”„๋กœ๊ทธ๋ž˜๋ฐํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ•œ๋‹ค. interactive programming languageSwift์—์„œ ๊ฐ•์กฐ๋˜๋Š” ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” ์ƒํ˜ธ์ž‘์šฉ์ด๋‹ค. ์ปดํŒŒ์ผ ์–ธ์–ด์ž„์—๋„, ์ปดํŒŒ์ผ๋Ÿฌ๊ฐ€ ์ตœ์ ํ™”๋˜์–ด์žˆ์–ด ๋งˆ์น˜ ์Šคํฌ๋ฆฝํŠธ ์–ธ์–ด์ฒ˜๋Ÿผ ์‹ค์‹œ๊ฐ„์œผ๋กœ ์ƒํ˜ธ์ž‘์šฉํ•˜๋ฉฐ ํ”„๋กœ๊ทธ๋ž˜๋ฐํ•  ์ˆ˜ ์žˆ๋‹ค.์ปดํŒŒ์ผ..

Swift 2023.10.08

[ Swift ] zip(_:_:)

Documentation /Swift /Swift Standard Library /Collections /zip(_:_:) zip(_:_:) func zip( _ sequence1: Sequence1, _ sequence2: Sequence2 ) -> Zip2Sequence where Sequence1 : Sequence, Sequence2 : Sequence ๋‘ ๊ฐœ์˜ sequence๋กœ ๊ตฌ์„ฑํ•œ sequence ์Œ์„ ๋งŒ๋“œ๋Š” ํ•จ์ˆ˜์ด๋‹ค. Array, String, Range์ฒ˜๋Ÿผ Sequence ํ”„๋กœํ† ์ฝœ์„ ์ฑ„ํƒํ•œ ํƒ€์ž…์ด ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์˜จ๋‹ค. ์ฆ‰, ์ˆœ์„œ๊ฐ€ ์žˆ๋Š” ํƒ€์ž…์„ ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ๊ฐ€์ง„๋‹ค ํŠœํ”Œ sequence ๋ฐ˜ํ™˜ zip์„ ์‚ฌ์šฉํ•ด ๋‘ sequence๋ฅผ ํ•ฉ์น˜๋ฉด ๊ฐ ์›์†Œ๋“ค์ด ๋™์ผํ•œ ์ธ๋ฑ์Šค ์›์†Œ๋“ค๊ณผ ์ง์„ ์ง€์–ด ํŠœํ”Œ ํƒ€์ž…์˜ Z..

Swift 2023.10.08

[ Rx ] ๊ฒฐํ•ฉ ์—ฐ์‚ฐ - 1. withLatestFrom

withLatestFrom func withLatestFrom(_ second: Source) -> Observable where Source : ObservableConvertibleType Summary ํ•ด๋‹น ์˜ต์ ธ๋ฒ„๋ธ”์ด element๋ฅผ ๋ฐฉ์ถœํ•  ๋•Œ๋งˆ๋‹ค ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์˜ ๊ฐ€์žฅ ์ตœ์‹  element๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‘ ๊ฐœ์˜ ์˜ต์ ธ๋ฒ„๋ธ”์„ ํ•œ ๊ฐœ์˜ ์˜ต์ ธ๋ฒ„๋ธ”๋กœ ๋ณ‘ํ•ฉํ•œ๋‹ค. Discussion Note ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์ด element๋ฅผ ๋ฐฉ์ถœํ•˜๊ธฐ ์ „, ํ•ด๋‹น ์˜ต์ ธ๋ฒ„๋ธ”์ด element๋ฅผ ๋ฐฉ์ถœํ•œ๋‹ค๋ฉด ๊ทธ๊ฑด ๋ˆ„๋ฝ๋  ๊ฒƒ์ด๋‹ค. ์ฆ‰, ์•„๋ฌด๋Ÿฐ ์ž‘์—…๋„ ์ผ์–ด๋‚˜์ง€ ์•Š๋Š”๋‹ค. Parameters ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ๋Š” ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์ด ์˜จ๋‹ค Returns ํ•ด๋‹น ์˜ต์ ธ๋ฒ„๋ธ”์˜ element์™€ ๋‘ ๋ฒˆ์งธ ์˜ต์ ธ๋ฒ„๋ธ”์˜ ์ตœ์‹  element ๊ฐ๊ฐ์„ ๊ฒฐํ•ฉํ•œ ๊ฒฐ๊ณผ๋ฅผ ํฌํ•จํ•˜๋Š”..

iOS/Rx 2023.10.06

[ Swift ] isCase | isLowercase | isUppercase

isCase ํ•ด๋‹น Character์˜ ๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ™˜์ด ๊ฐ€๋Šฅ ์—ฌ๋ถ€๋ฅผ ์•Œ ์ˆ˜ ์žˆ๋Š” ํ”„๋กœํผํ‹ฐ์ด๋‹ค. String์ด ์•„๋‹ˆ๋ผ Character์˜ ์ธ์Šคํ„ด์Šค ํ”„๋กœํผํ‹ฐ๋ผ๋Š” ์ ์„ ์ฃผ์˜ํ•˜์ž. ๋Œ€์†Œ๋ฌธ์ž๊ฐ€ ์žˆ๋Š” ์˜์–ด๋Š” ture์ด์ง€๋งŒ ํ•œ๊ธ€, ์•„์ด์ฝ˜, ํŠน์ˆ˜๋ฌธ์ž ๋“ฑ์€ false์ด๋‹ค. let english = "a" let korean = "๊ฐ€" let icon = "๐Ÿงš๐Ÿป‍โ™€๏ธ" let half = "½" if english.first!.isCased { print(english) } // Prints "a" if korean.first!.isCased { print(korean) } if icon.first!.isCased { print(icon) } if half.first!.isCased { print(half) } isLowe..

Swift 2023.10.04

[ Swift ] print(_:separator:terminator:)

print(_:separator:terminator:) func print( _ items: Any..., separator: String = " ", terminator: String = "\n" ) ์ฃผ์–ด์ง„ ์•„์ดํ…œ์˜ ํ…์ŠคํŠธ ํ‘œํ˜„์„ ํ‘œ์ค€ ์ถœ๋ ฅํ•œ๋‹ค. items๋ฅผ ์ œ์™ธํ•œ ๋‹ค๋ฅธ ๋งค๊ฐœ๋ณ€์ˆ˜๋Š” ๊ธฐ๋ณธ๊ฐ’์ด ์„ค์ •๋˜์–ด์žˆ๊ธฐ ๋•Œ๋ฌธ์— ํ•จ์ˆ˜ ํ˜ธ์ถœ ์‹œ ๊ฐ’์„ ์ „๋‹ฌํ•˜์ง€ ์•Š์•„๋„ ๋œ๋‹ค. Items items์€ Any ํƒ€์ž…์œผ๋กœ, ํƒ€์ž…๊ณผ ์•„์ดํ…œ์˜ ๊ฐœ์ˆ˜์— ์ƒ๊ด€์—†์ด ํ…์ŠคํŠธ๋กœ ํ‘œํ˜„๋˜์–ด ์ถœ๋ ฅ๋œ๋‹ค. items๋Š” String(item)๊ณผ ๊ฐ™์€ ์ž‘์—…์„ ์ž๋™์œผ๋กœ ํ•ด์ฃผ๊ธฐ ๋•Œ๋ฌธ์— ํƒ€์ž… ๋ณ€ํ™˜์„ ํ•ด์ฃผ์ง€ ์•Š์•„๋„ ๋œ๋‹ค let number: Int = 120 print(number) // Prints "120" seperator separator์€ ์—ฌ๋Ÿฌ ์•„์ดํ…œ์ด ์žˆ์„..

Swift 2023.10.04

[ Swift ] ํ”„๋กœํ† ์ฝœ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ

Swift๋Š” ํ”„๋กœํ† ์ฝœ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ 2015๋…„ ํ”„๋กœํ† ์ฝœ Extension์ด ๋„์ž…๋œ Swift 2.0 ๋ฒ„์ „์ด ๋ฐœํ‘œ๋˜๋ฉฐ Apple์€ Swift๊ฐ€ ํ”„๋กœํ† ์ฝœ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด๋ผ ์„ ์–ธํ–ˆ๋‹ค. ๋”ํ•ด ํ”„๋กœํ† ์ฝœ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์€ ์ฐธ์กฐ ํƒ€์ž…์ธ ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๋ณด๋‹ค ๊ฐ’ ํƒ€์ž…์„ ๋” ํšจ์œจ์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋ฉฐ, ์˜ค๋ฅ˜๋ฅผ ์ค„์ผ ๋ฐฉ์•ˆ์ด๋ผ ์†Œ๊ฐœํ–ˆ๋‹ค. ์ด์ œ ์Šค์œ„ํ”„ํŠธ์—์„œ๋Š” ํด๋ž˜์Šค์—์„œ ํ–ˆ๋˜ ๊ฒƒ์ฒ˜๋Ÿผ ๊ตฌ์กฐ์ฒด์™€ ์—ด๊ฑฐํ˜•์— ์บก์Šํ™”, ์ถ”์ƒํ™”, ์ ‘๊ทผ ์ œ์–ด ๋“ฑ์˜ ๊ธฐ๋Šฅ์„ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์œผ๋ฉฐ, ์ฐธ์กฐ ํƒ€์ž…์˜ ์ฐธ์กฐ ๋ฌธ์ œ์—์„œ ๋” ์ž์œ ๋กœ์šธ ์ˆ˜ ์žˆ๊ณ  ๋‹ค์ค‘์ƒ์†๊ณผ ๋” ๋‚˜์€ ์ถ”์ƒํ™” ๋ฉ”์ปค๋‹ˆ์ฆ˜์„ ๊ตฌํ˜„ ์ˆ˜ ์žˆ๊ฒŒ ๋˜์—ˆ๋‹ค. ํ”„๋กœํ† ์ฝœ ํ”„๋กœํ† ์ฝœ์ด๋ž€ ํŠน์ • ์ž‘์—…์— ๋งž๋Š” ๋ฉ”์„œ๋“œ์™€ ํ”„๋กœํผํ‹ฐ๋ฅผ ์ •์˜ํ•˜๋Š” ์ฒญ์‚ฌ์ง„์ด๋‹ค. ํด๋ž˜์Šค๋Š” ํด๋ž˜์Šค๋งŒ ์ƒ์†ํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ๊ณผ ๋‹ค๋ฅด๊ฒŒ, ํ”„๋กœํ† ์ฝœ์€ ํด๋ž˜์Šค, ๊ตฌ์กฐ์ฒด, ์—ด๊ฑฐํ˜•์ด..

Swift 2023.09.24

[ iOS ์‹œํ–‰์ฐฉ์˜ค ] URLSession์œผ๋กœ multipart/form-data ์š”์ฒญ

๐Ÿ‘ฉ‍๐Ÿ’ป๋ฐฐ๊ฒฝ๐Ÿ‘ฉ‍๐Ÿ’ป์•จ๋ฒ”์—์„œ ์ด๋ฏธ์ง€๋ฅผ ์„ ํƒํ•ด ์„œ๋ฒ„๋กœ ์ „์†กํ•˜๋Š” ์ž‘์—…์ด ์ฃผ์–ด์กŒ๋‹ค. ์ด์ „์— ๋ช‡ ๋ฒˆ ์ด๋ฏธ์ง€๋ฅผ ์š”์ฒญํ•˜๊ณ  ๋ฐ›์•„๋ณธ ๊ฒฝํ—˜์ด ์žˆ์–ด ๋ฌด๋ฆฌ๊ฐ€ ์—†์„ ๊ฑฐ๋ผ ์ƒ๊ฐํ–ˆ์ง€๋งŒ, ๊ทธ๋•Œ๋Š” 3rd party์ธ Alamofire๋ฅผ ์‚ฌ์šฉํ–ˆ์–ด์„œ ๊ฐ„๋‹จํ–ˆ์—ˆ๊ณ  ์ง€๊ธˆ์€ Apple์˜ built-in์ธ URLSession์„ ์‚ฌ์šฉํ•ด์•ผํ•ด์„œ ๋งŽ์ด ํ—ท๊ฐˆ๋ ธ๋‹ค.   ๐Ÿ˜ฎ cURL Vs HTTPAPI๋ฌธ์„œ๋Š” ํ‘œํ˜„์˜ ์ฐจ์ด ๋“ฑ์œผ๋กœ iOS๋งŒ ์•Œ๊ณ  ์žˆ์–ด์„œ๋Š” ์™„์ „ํžˆ ์ดํ•ดํ•˜๊ธฐ ์–ด๋ ต๋‹ค. ๊ทธ๋™์•ˆ ํ•ด์™”๋˜ ์„œ๋ฒ„ ์—ฐ๊ฒฐ ๊ฒฝํ—˜๊ณผ ๊ตฌ๊ธ€๋ง์„ ๋ฐ”ํƒ•์œผ๋กœ ์ง€๊ธˆ๊นŒ์ง€ ์ž˜ ์ดํ•ดํ•˜๋ฉฐ ์—ฐ๊ฒฐํ•ด์™”๋‹ค. ์˜ค๋žœ๋งŒ์— ์ด๋ฏธ์ง€ ์—…๋กœ๋“œ ์„œ๋ฒ„ ์—ฐ๊ฒฐ์„ ํ•˜๋ ค๊ณ  ๋ณด๋‹ˆ API๋ฅผ ์ดํ•ดํ•˜๊ธฐ ์–ด๋ ค์› ๋‹ค. ๋‚ด๊ฐ€ ๋”ฐ๋กœ ์ฐพ์•„ ๊ณต๋ถ€ํ–ˆ๋˜ mutipart/form-data ์—ฐ๊ฒฐ ๊ตฌ์กฐ์™€๋Š” ๋งŽ์ด ๋‹ฌ๋ผ ๋ฐฉ๋ฒ•์ด ๋‹ค์–‘ํ•œ๊ฑด๊ฐ€ ์‹ถ์–ด ๊ตฌ๊ธ€๋ง์„ ์ •๋ง ..

[ iOS ] Link Presentation ์•Œ์•„๋ณด๊ธฐ

Link Presentation | Apple Developer Documentation Fetch, provide, and present rich links in your app. developer.apple.com ๐ŸŽฌ ๊ธ€์„ ์‹œ์ž‘ํ•˜๋ฉฐ Link Presentation์€ ์•ฑ์„ ๊ฐœ๋ฐœํ•  ๋•Œ ์‚ฌ์šฉํ–ˆ๋˜ Framework๋กœ, Share Sheet๋ฅผ ์ž„์˜๋กœ ๊ตฌ์„ฑํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ–ˆ๋‹ค. ํ•˜์ง€๋งŒ title๊ณผ content๋งŒ์œผ๋กœ ๊ตฌ์„ฑํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ด framework๋ฅผ ์ž˜ ์‚ฌ์šฉํ–ˆ๋‹ค๊ณ  ํ•˜๊ธด ์–ด๋ ต๋‹ค. ์ด๋ฒˆ์— ํ”„๋กœ์ ํŠธ์—์„œ ๋ชจ์ž„ ์ •๋ณด๋ฅผ ๊ณต์œ ํ•  ๋•Œ ๋งํฌ๋ฅผ ์ฒจ๋ถ€ํ•˜๊ธฐ ์œ„ํ•ด Link Presentation๋ฅผ ์‚ฌ์šฉํ•  ์˜ˆ์ •์ด๋‹ค. ๊ทธ ์ „์— ๊ณต์‹ ๋ฌธ์„œ์™€ WWDC ์˜์ƒ์„ ํ†ตํ•ด Link Presentation์„ ๊ผผ๊ผผํ•˜๊ฒŒ ์ •๋ฆฌํ•˜๋ ค ํ•œ๋‹ค. โœ‰๏ธ Link ..

iOS 2023.08.18

[ iOS ] Bounds์™€ Frame ๋น„๊ต - 2. Size

๐Ÿค” ๋ฌธ์ œ ๐Ÿค” Bounds์™€ Frame์˜ ์ฐจ์ด๋Š” ๋ญ˜๊นŒ? UIView์—๋Š” bounds ํ”„๋กœํผํ‹ฐ์™€ frame ํ”„๋กœํผํ‹ฐ๊ฐ€ ์žˆ๋‹ค. ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋ด๋„ ๋‘˜์˜ ์ฐจ์ด๋Š” ํฌ๊ฒŒ ์™€๋‹ฟ์ง€ ์•Š๋Š”๋‹ค. ๋”ฐ๋ผ์„œ StoryBoad๋ฅผ ์‚ฌ์šฉํ•ด ์‹ค์Šตํ•˜๋ฉฐ View์˜ Bounds์™€ Frame์„ ๋น„๊ต ๋ถ„์„ ํ•ด๋ณด์ž! 1ํŽธ ๋ณด๊ธฐ [ iOS ] Bounds์™€ Frame ๋น„๊ต - 1. ๊ณต์‹๋ฌธ์„œ์™€ origin ๐Ÿค” ๋ฌธ์ œ ๐Ÿค” Bounds์™€ Frame์˜ ์ฐจ์ด๋Š” ๋ญ˜๊นŒ? UIView์—๋Š” bounds ํ”„๋กœํผํ‹ฐ์™€ frame ํ”„๋กœํผํ‹ฐ๊ฐ€ ์žˆ๋‹ค. ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋ด๋„ ๋‘˜์˜ ์ฐจ์ด๋Š” ํฌ๊ฒŒ ์™€๋‹ฟ์ง€ ์•Š๋Š”๋‹ค. ๋”ฐ๋ผ์„œ StoryBoad๋ฅผ ์‚ฌ์šฉํ•ด ์‹ค์Šตํ•˜๋ฉฐ View์˜ Bounds์™€ Fra 88yhtserof.tistory.com 2. Size 1ํŽธ์— ์ด์–ด 2ํŽธ์—์„œ๋Š” bounds์™€ frame..

iOS 2023.07.01

[ iOS ] Bounds์™€ Frame ๋น„๊ต - 1. ๊ณต์‹๋ฌธ์„œ์™€ origin

๐Ÿค” ๋ฌธ์ œ ๐Ÿค” Bounds์™€ Frame์˜ ์ฐจ์ด๋Š” ๋ญ˜๊นŒ? UIView์—๋Š” bounds ํ”„๋กœํผํ‹ฐ์™€ frame ํ”„๋กœํผํ‹ฐ๊ฐ€ ์žˆ๋‹ค. ๊ณต์‹ ๋ฌธ์„œ๋ฅผ ๋ด๋„ ๋‘˜์˜ ์ฐจ์ด๋Š” ํฌ๊ฒŒ ์™€๋‹ฟ์ง€ ์•Š๋Š”๋‹ค. ๋”ฐ๋ผ์„œ StoryBoad๋ฅผ ์‚ฌ์šฉํ•ด ์‹ค์Šตํ•˜๋ฉฐ View์˜ Bounds์™€ Frame์„ ๋น„๊ต ๋ถ„์„ ํ•ด๋ณด์ž! 1. ๊ณต์‹๋ฌธ์„œ์™€ origin ๐Ÿ“š๊ณต์‹๋ฌธ์„œ ํ™•์ธํ•˜๊ธฐ Bounds์˜ ๊ณต์‹๋ฌธ์„œ /UIKit /Views and controls /UIView /bounds Instance Property bounds ์ž์ฒด ์ขŒํ‘œ ์‹œ์Šคํ…œ์œผ๋กœ ํ•ด๋‹น view์˜ ์œ„์น˜์™€ ํฌ๊ธฐ๋ฅผ ํ‘œํ˜„ํ•˜๋Š” ๊ฒฝ๊ณ„ ์‚ฌ๊ฐํ˜• ๊ธฐ๋ณธ์ ์ธ bound ์›์ ์€ (0, 0)์ด๊ณ , size๋Š” frame ํ”„๋กœํผํ‹ฐ์— ์žˆ๋Š” ์‚ฌ๊ฐํ˜•์˜ size์™€ ๋™์ผํ•˜๋‹ค. ์ด ์‚ฌ๊ฐํ˜•์˜ size ๋ณ€ํ™”๋Š” center point๋ฅผ ๊ธฐ์ค€์œผ..

iOS 2023.06.30

[ iOS/Rx ] 1. RxSwift๋ž€?

๐Ÿงš๐Ÿป‍โ™€๏ธ์š”์•ฝ๐Ÿงš๐Ÿป‍โ™€๏ธ Rx๋Š” Observable ํ˜•ํƒœ๋กœ ํ‘œํ˜„๋˜๋Š” ๋น„๋™๊ธฐ์  ๋ฐ์ดํ„ฐ ํ๋ฆ„์„ ์‚ฌ์šฉํ•œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด๋‹ค. ๊ทธ๊ฒƒ์ด ๊ธฐ๋ฐ˜์ด ๋˜์–ด Swift ์ „์šฉ์œผ๋กœ ๊ตฌํ˜„๋œ ๊ฒƒ์ด ๋ฐ”๋กœ RxSwift์ด๋‹ค. Rx๋Š” ๋น„๋™๊ธฐ์  ์ž‘์—…๊ณผ ๋ฐ์ดํ„ฐ ํ๋ฆ„ ๊ตฌ์„ฑ์„ ์‰ฝ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ๋˜๋ฉฐ ๋ฐ˜์‘ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด์ž ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ์œผ๋กœ ๋˜์–ด์žˆ๋‹ค. ์ „๋‹ฌ๋˜๋Š” ์ด๋ฒคํŠธ์— ๋ฐ”๋กœ ๋ฐ˜์‘ํ•˜์—ฌ ์ž‘์—…์ด ์ด๋ฃจ์–ด์ง„๋‹ค. Reactive ๊ตฌ์„ฑ ์š”์†Œ๋กœ๋Š” Observable(๊ด€์ฐฐ๋Œ€์ƒ), Operator(์—ฐ์‚ฐ์ž), Observer(๊ด€์ฐฐ์ž)๊ฐ€ ์žˆ์œผ๋ฉฐ, ๊ด€์ฐฐ์ž๊ฐ€ ๊ด€์ฐฐ๋Œ€์ƒ์„ ๊ตฌ๋…(Subscribe)ํ•ด์•ผ๋งŒ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. ๋ฐ์ดํ„ฐ ํ๋ฆ„๋“ค์ด ์ด๋ฒคํŠธ์— ๋‹ด๊ฒจ Observable์—์„œ ์‹œ์ž‘ํ•ด Operator์„ ๊ฑฐ์ณ Observer์—๊ฒŒ ๋„๋‹ฌํ•œ๋‹ค. ๋น„๋™๊ธฐ ์ž‘์—… Rx์— ๋Œ€ํ•ด ์•Œ๊ธฐ ์ „ ..

iOS/Rx 2023.06.27

[ iOS ] ๋™๊ธฐ์™€ ๋น„๋™๊ธฐ / ์ง๋ ฌ๊ณผ ๋™์‹œ์„ฑ

๊ณต๋ถ€ ๋ฐฐ๊ฒฝ RxSwift๋ฅผ ๊ณต๋ถ€ํ•˜๋ ค ํ•˜๋Š”๋ฐ ๊ทธ์ „์— ๋จผ์ € ๋น„๋™๊ธฐ์— ๋Œ€ํ•ด ์ž˜ ์•Œ๊ณ  ์žˆ์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™์•˜๋‹ค. ๋™๊ธฐ์™€ ๋น„๋™๊ธฐ๋ฅผ ๋ฐฐ์› ์ง€๋งŒ ์ œ๋Œ€๋กœ ์•„๋Š” ๊ฒƒ ๊ฐ™์ง€ ์•Š์•„ ์ด๋ฒˆ ๊ธฐํšŒ์— ์ •๋ฆฌ๋ฅผ ํ•˜๊ณ , ํ•จ๊ป˜ ์ง๋ ฌ๊ณผ ๋™์‹œ์„ฑ๋„ ๊ณต๋ถ€ํ•ด์„œ 4๊ฐ€์ง€์˜ ์ฐจ์ด๋ฅผ ๋ถ„๋ช…ํžˆ ์•Œ๊ณ ์ž ํ•œ๋‹ค. ๊ธฐ๋ณธ ์ผ๋‹จ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ–ˆ์„ ๋•Œ์—๋Š” ์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ ์ž‘์—…์ด ์ฒ˜๋ฆฌ๋œ๋‹ค. ๋ฉ”์ธ ์Šค๋ ˆ๋“œ๊ฐ€ ๋ชจ๋“  ์ผ์„ ์ „๋ถ€ ์ฒ˜๋ฆฌํ•˜๊ฒŒ ๋˜์–ด ํ™”๋ฉด ๋กœ๋“œ๊ฐ€ ์˜ค๋ž˜ ๊ฑธ๋ฆฌ๋Š” ๋“ฑ ๋ฌธ์ œ๊ฐ€ ๋งŽ๋‹ค. ์ด๋Š” ์‚ฌ์šฉ์ž ๊ฒฝํ—˜์„ ์•ˆ ์ข‹๊ฒŒ ๋งŒ๋“ค์–ด์„œ ์šฐ๋ฆฌ๋Š” ์ฃผ์˜ํ•ด์•ผ ํ•  ํ•„์š”๊ฐ€ ์žˆ๋‹ค. ๋™๊ธฐ์™€ ๋น„๋™๊ธฐ ๋™๊ธฐ์™€ ๋น„๋™๊ธฐ๋Š” ๋‘˜๋‹ค ๋‹ค๋ฅธ ์Šค๋ ˆ๋“œ๋กœ ์ž‘์—…์„ ๋ณด๋‚ธ๋‹ค๋Š” ๊ณตํ†ต์ ์ด ์žˆ๋‹ค. ๋‘˜์˜ ์ฐจ์ด์ ์€ ์ž‘์—…์„ ๋ณด๋‚ด๋†“๊ณ  ๊ธฐ๋‹ค๋ฆฌ๋Š๋ƒ(Block) ๋˜๋Š” ๋‹ค์Œ์œผ๋กœ ํ•ด์•ผํ•˜๋Š” ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•˜๋Š๋ƒ์˜ ์ฐจ์ด์ด๋‹ค. ๋™๊ธฐ๋Š” ์ž‘์—…์„ ๋ณด๋‚ด๋†“๊ณ  ๊ทธ ์ž‘์—…์ด..

iOS 2023.06.22
728x90