๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Swift) ์—ฐ์‚ฐ์ž == ์™€ === ์˜ ์ฐจ์ด == ์—ฐ์‚ฐ์ž a == b: a์˜ ๊ฐ’๊ณผ b์˜ ๊ฐ’์ด ๊ฐ™์€์ง€ ๊ฐ’์„ ๋น„๊ต let value1 = 1 let value2 = 2 print(value1 == value2) // false === ์—ฐ์‚ฐ์ž a === b: a๊ฐ€ ์ฐธ์กฐํ•˜๊ณ  ์žˆ๋Š” ์ธ์Šคํ„ด์Šค์™€ b๊ฐ€ ์ฐธ์กฐํ•˜๊ณ  ์žˆ๋Š” ์ธ์Šคํ„ด์Šค๊ฐ€ ๊ฐ™์€์ง€ ๋ ˆํผ๋Ÿฐ์Šค๋ฅผ ๋น„๊ต let p1 = Person(id: 1, name: "kim") let p2 = Person(id: 1, name: "kim") let p3 = p1 print(p1 === p2) // false print(p1 === p3) // true `==`๋Š” stack ์˜์—ญ์˜ ๊ฐ’์„ ๋น„๊ต, `===`๋Š” heap ์˜์—ญ์˜ ๊ฐ’์„ ๋น„๊ต ์ฐธ๊ณ ์ž๋ฃŒ https://developer.apple.com/documentation/swift/=.. 2022. 9. 24.
Property Wrapper Property Wrapper A property wrapper adds a layer of separation between code that manages how a property is stored and the code that defines a property. For example, if you have properties that provide thread-safety checks or store their underlying data in a database, you have to write that code on every property. When you use a property wrapper, you write the management code once when you define.. 2022. 4. 28.
self vs Self ์†Œ๋ฌธ์ž self ์ธ์Šคํ„ด์Šค ์ž์ฒด ์ ‘๊ทผ ์‹œ ์‚ฌ์šฉ๋˜๋Š” ์ฐธ์กฐ๊ฐ’ self๋Š” ์ฐธ์กฐ ํƒ€์ž… value type์—์„œ์˜ self๋Š” stack์˜์—ญ์— ์กด์žฌํ•˜๋Š” instance๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํ˜•ํƒœ reference type์—์„œ์˜ self๋Š” heap ์˜์—ญ์— ์กด์žฌํ•˜๋Š” instance๋ฅผ ๊ฐ€๋ฆฌํ‚ค๋Š” ํ˜•ํƒœ ๋Œ€๋ฌธ์ž Self Self๋Š” type๊ทธ ์ž์ฒด๋ฅผ ์˜๋ฏธ -> ํƒ€์ž…์„ ์ •์˜ํ• ๋•Œ ์‚ฌ์šฉ Self.self๋Š” type object๋ฅผ ์˜๋ฏธ -> ํƒ€์ž…์„ ๋„˜๊ธธ๋•Œ ์‚ฌ์šฉ protocol ๋‚ด๋ถ€์—์„œ์˜ Self ์˜๋ฏธ: protocol ์ž์‹ ์ด ์•„๋‹Œ, ์ž๊ธฐ ์ž์‹ ์„ ์ฑ„ํƒํ•œ ํƒ€์ž…์„ ์˜๋ฏธ Class์—์„œ์˜ Self ์˜๋ฏธ : ํ•ด๋‹น ์ธ์Šคํ„ด์Šค์˜ ํƒ€์ž… ์ž์ฒด๋ฅผ ํ‘œํ˜„ ์ฐธ๊ณ ์ž๋ฃŒ https://ios-development.tistory.com/600 2022. 4. 27.
RxSwift Operator : Map, FlatMap Map transform the items emitted by an Observable by applying a function to each item map์€ ์ด๋ฒคํŠธ๋ฅผ ๋ฐ”๊พผ๋‹ค. E Type์ด๋ฒคํŠธ๋ฅผ R Type์ด๋ฒคํŠธ๋กœ ๋ฐ”๊พผ๋‹ค map์€ ํด๋กœ์ €์— ์—ฐ์‚ฐ ๊ฐ’์„ ๋ฆฌํ„ด์‹œํ‚จ๋‹ค observable๋กœ ๋ถ€ํ„ฐ emit๋˜๋Š” item์„ ๋‹ค๋ฅธ ํƒ€์ž…์œผ๋กœ ๋ฐ”๊พธ๊ณ  ์‹ถ์„๋•Œ map์ด ์‚ฌ์šฉ๋œ๋‹ค FlatMap transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable ์ด๋ฒคํŠธ๋‹น ํ•œ ๊ฐœ์˜ ์ƒˆ๋กœ์šด Observable ์‹œํ€€์Šค๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. ์ด๋ ‡๊ฒŒ ์ƒ์„ฑ๋œ ์—ฌ๋Ÿฌ๊ฐœ์˜ ์ƒˆ๋กœ์šด ์‹œํ€€์Šค๋ฅผ ํ•˜๋‚˜์˜ .. 2022. 4. 18.
typealias, associatedtype typealias typealias๋ž€ ํƒ€์ž…์— ๋ถ™์ผ ์ˆ˜ ์žˆ๋Š” ๋ณ„์นญ associatedtype associatedType ์€ Protocol์„ ์œ„ํ•œ Generic An associated type gives a placeholder name to a type that’s used as part of the protocol. ์ฐธ๊ณ ์ž๋ฃŒ https://docs.swift.org/swift-book/LanguageGuide/Generics.html https://woongsios.tistory.com/97 2022. 4. 15.
Non-Escaping Closure ์™€ Escaping Closure Non-Escaping ํด๋กœ์ €๋Š” ํ•จ์ˆ˜์˜ ์ธ์ž๋กœ ์ „๋‹ฌ๋์„ ๋•Œ, ํ•จ์ˆ˜์˜ ์‹คํ–‰์ด ์ข…๋ฃŒ๋˜๊ธฐ ์ „์— ์‹คํ–‰๋˜๋Š” ํด๋กœ์ €. Escaping ํด๋กœ์ €๋Š” ํด๋กœ์ €๊ฐ€ ํ•จ์ˆ˜์˜ ์ธ์ž๋กœ ์ „๋‹ฌ๋์„ ๋•Œ, ํ•จ์ˆ˜์˜ ์‹คํ–‰์ด ์ข…๋ฃŒ๋œ ํ›„ ์‹คํ–‰๋˜๋Š” ํด๋กœ์ €. Non-Escaping ํด๋กœ์ € func runClosure(closure: () -> Void) { closure() } ํด๋กœ์ €๊ฐ€ ์‹คํ–‰๋˜๋Š” ์ˆœ์„œ๋ฅผ ๋ณด๋ฉด ํด๋กœ์ €๊ฐ€ runClosure() ํ•จ์ˆ˜์˜ closure ์ธ์ž๋กœ ์ „๋‹ฌ๋จ ํ•จ์ˆ˜ ์•ˆ์—์„œ closure() ๊ฐ€ ์‹คํ–‰๋จ runClosure() ํ•จ์ˆ˜๊ฐ€ ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜๊ณ  ์ข…๋ฃŒ๋จ ์ด๋ ‡๊ฒŒ ํด๋กœ์ €๊ฐ€ ํ•จ์ˆ˜๊ฐ€ ์ข…๋ฃŒ๋˜๊ธฐ ์ „์— ์‹คํ–‰๋˜๊ธฐ ๋•Œ๋ฌธ์— closure๋Š” Non-Escaping ํด๋กœ์ €์ด๋‹ค. Escaping ํด๋กœ์ € func makeRequest(_ completion: @.. 2021. 12. 28.