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

IOS๐ŸŽ45

[Swift] split, components ์ฐจ์ด (with: ์„ฑ๋Šฅ) ์ฝ”ํ…Œ ๋ฌธ์ œ๋ฅผ ํ’€๋‹ค๊ฐ€ ๋‚˜๋Š” ์™„์ „ ๋น„ํšจ์œจ์ ์œผ๋กœ ์งฐ์ง€๋งŒ ๐Ÿ˜ž ๋‹ค๋ฅธ ์‚ฌ๋žŒ ์ฝ”๋“œ ์ค‘ components()๋ฅผ ์“ด ์ฝ”๋“œ๊ฐ€ ์žˆ์–ด ์ด๊ฑด ๋ญ์ง€..? ๋ผ๋Š” ๊ถ๊ธˆ์ฆ์ด ๋“ค์—ˆ์–ด์š” ! split()ํ•จ์ˆ˜์™€ ๋น„์Šทํ•œ๊ฑฐ ๊ฐ™์€๋ฐ ์ฐจ์ด์ ์„ ์ž˜ ๋ชจ๋ฅด๊ฒ ์–ด์„œ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ตฌ ํ•ฉ๋‹ˆ๋‹ค !! split() ํŒŒ๋ผ๋ฏธํ„ฐ์— ๋Œ€ํ•ด ์‚ดํŽด๋ด…์‹œ๋‹ค separator : ์ชผ๊ฐค ๋‹จ์œ„ maxSpilts : ์ตœ๋Œ€ ์–ผ๋งˆ๋‚˜ ์ชผ๊ฐค์ง€ // default : Int.max ()omittingEmptySubsequences : ๊ฒฐ๊ณผ ๊ฐ’์—์„œ ๋นˆ์‹œํ€€์Šค ํฌํ•จํ• ์ง€ false๋ผ๋ฉด ์ชผ๊ฐ  ๋ฐฐ์—ด์ด ๋นˆ ๋ฐฐ์—ด์ผ์ง€๋ผ๋„ ๋ฐ˜ํ™˜ํ•œ๋‹ค. true๋ผ๋ฉด ๋นˆ๋ฐฐ์—ด์€ ์ƒ๋žตํ•˜๊ณ  ๋ฐ˜ํ™˜ํ•œ๋‹ค // default : true return๋˜๋Š” ํƒ€์ž… : [subString] Components() ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ spilt()๋ณด๋‹ค ๊ฐ„๋‹จํ•ด๋ณด์ž…๋‹ˆ.. 2022. 4. 14.
[Swift] Opaque Type์ด๋ž€ SwiftUI๋ฅผ ๋ณด๋ฉด body์— some ํ‚ค์›Œ๋“œ๊ฐ€ ๋ถ™์€๊ฑธ ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๊ฒŒ ๋ญ”์ง€ ๊ถ๊ธˆํ•ด์ ธ์„œ ์ฐพ์•„๋ณด๊ณ  ์ •๋ฆฌํ•˜๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค ๐Ÿค” ์ฐธ๊ณ  ์ž๋ฃŒ : https://docs.swift.org/swift-book/LanguageGuide/OpaqueTypes.html Opaque Types — The Swift Programming Language (Swift 5.6) Opaque Types A function or method with an opaque return type hides its return value’s type information. Instead of providing a concrete type as the function’s return type, the return value is desc.. 2022. 4. 12.
[iOS] Swift Unit Test ์‚ดํŽด๋ณด๊ธฐ Unit Test๋ž€ ? ๋‹จ์œ„ ํ…Œ์ŠคํŠธ, ํŠน์ • ๊ธฐ๋Šฅ์ด ์˜๋„ํ•œ๋Œ€๋กœ ์ž˜ ์ž‘๋™๋˜๋Š”์ง€ ์ ๊ฒ€ํ•˜๊ธฐ ์œ„ํ•ด ์ž‘์„ฑํ•˜๋Š” ์ฝ”๋“œ๋ฅผ ๋งํ•œ๋‹ค. ๋ฒ„๊ทธ์— ๋Œ€ํ•œ ๊ฐ€๋Šฅ์„ฑ์„ ๋‚ฎ์ถ”๊ณ  ์ฝ”๋“œ๋ฅผ ๊ฐœ์„ ํ•˜๊ธฐ ์œ„ํ•ด ์ž‘์„ฑํ•˜๋Š” ๊ฒƒ์ด ์ค‘์š”ํ•˜๋‹ค. Xcode์—์„œ "Include Test"๋ฅผ ์„ ํƒํ•˜๋ฉด ํ”„๋กœ์ ํŠธ์ด๋ฆ„-Test, ํ”„๋กœ์ ํŠธ์ด๋ฆ„-UITest ๋‘๊ฐœ๊ฐ€ ๋งŒ๋“ค์–ด์ง„๋‹ค. ๋งŒ์•ฝ ์ฒ˜์Œ๋ถ€ํ„ฐ ํ…Œ์ŠคํŠธ ํ•  ์ƒ๊ฐ์ด ์—†์–ด "Include Test" ์ฒดํฌํ•˜์ง€ ์•Š๊ณ  ํ”„๋กœ์ ํŠธ๋ฅผ ์ƒ์„ฑํ–ˆ๋‹ค๋ฉด ? ์•„๋ž˜ ๊ทธ๋ฆผ์ฒ˜๋Ÿผ Xcode Test Navigator ํƒญ์„ ํด๋ฆญํ•˜๊ณ  unit test target์„ ํด๋ฆญํ•˜๋ฉด ํŒŒ์ผ์ด ์ƒ์„ฑ๋œ๋‹ค. ์–ด์จŒ๋“  ํŒŒ์ผ์„ ์ƒ์„ฑํ•˜๊ณ  ๋‚˜๋ฉด ์•„๋ž˜ ๊ทธ๋ฆผ๊ณผ ๊ฐ™๋‹ค. XCTestCase๋ฅผ ์ƒ์† ๋ฐ›๊ณ  ์žˆ๋‹ค. ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค, ๋ฉ”์†Œ๋“œ๋ฅผ ์ •์˜ํ•˜๋Š” ํด๋ž˜์Šค๋กœ ํ…Œ์ŠคํŠธ๋ฅผ ์œ„ํ•œ ํด๋ž˜์Šค๋กœ ์ƒ๊ฐํ•˜๋ฉด ๋ ๊ฑฐ ๊ฐ™๋‹ค... 2022. 4. 7.
[Swift] Access Control (open, public, internal, fileprivate, private) Access Control ๋ง ๊ทธ๋Œ€๋กœ ์ฝ”๋“œ์˜ ์ ‘๊ทผ์„ ์ œ์–ดํ•˜๋Š” ๊ธฐ๋Šฅ์ด๋‹ค. ๊ฐœ๋ณ„ ํƒ€์ž…(individual types)(ํด๋ž˜์Šค, ๊ตฌ์กฐ์ฒด ๋ฐ ์—ด๊ฑฐ) ๋ฟ๋งŒ์•„๋‹ˆ๋ผ, ํ•ด๋‹น ํƒ€์ž…์— ์†ํ•˜๋Š” ํ”„๋กœํผํ‹ฐ, ๋ฉ”์†Œ๋“œ, ์ด๋‹ˆ์…œ๋ผ์ด์ € ๋ฐ ์ฒจ์ž(subscripts)์— ๋Œ€ํ•ด ํŠน์ • ์ ‘๊ทผ ๋ ˆ๋ฒจ์„ ์ง€์ • ํ•  ์ˆ˜ ์žˆ๋‹ค. ํ”„๋กœํ† ์ฝœ์€ ์ „์—ญ ์ƒ์ˆ˜, ๋ณ€์ˆ˜ ๋ฐ ํ•จ์ˆ˜์ฒ˜๋Ÿผ ํŠน์ • ์ปจํ…์ŠคํŠธ๋กœ ์ œํ•œ๋œ๋‹ค. ์ ‘๊ทผ ์ œ์–ด๋Š” modules๊ณผ source file ๋Œ€์ƒ์œผ๋กœ ์ ์šฉ๋œ๋‹ค. swift๋Š” ์—”ํ‹ฐํ‹ฐ์— ๋Œ€ํ•ด 5๊ฐ€์ง€ ์ ‘๊ทผ ์ œ์–ด ๋ ˆ๋ฒจ์„ ๊ฐ€์ง„๋‹ค. open, public ์ •์˜๋œ ๋ชจ๋“ˆ๋‚ด ๋ชจ๋“  ์†Œ์Šค ํŒŒ์ผ ๋‚ด์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค. open ์ ‘๊ทผ์€ ํด๋ž˜์Šค ๋ฐ ํด๋ž˜์Šค ๋ฉค๋ฒ„์—๋งŒ ์ ์šฉ๋œ๋‹ค. struct, enum ๋“ฑ์˜ ํƒ€์ž…์€ Public์ด ๊ฐ€์žฅ ์ตœ์ƒ์œ„ ์ ‘๊ทผ ์ œ์–ด๋‹ค. ํด๋ž˜์Šค์™€ ํด๋ž˜์Šค ๋ฉค๋ฒ„์— .. 2022. 3. 29.
[RxSwift] Signal, ControlProperty, ControlEvent ๋ž€ ? ์ €๋ฒˆ Driver์— ์ด์–ด์„œ ๋‚˜๋จธ์ง€ Trait๋“ค๋„ ๋งˆ์ € ๋‹ค ์‚ดํŽด๋ณด๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. Signal signal์€ Driver์™€ ์œ ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Driver๋Š” subscribeํ•  ๋•Œ ํ•œ๋ฒˆ replay ํ•˜๋Š” ๋ฐ˜๋ฉด, Signal์€ ๊ทธ๋ ‡์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Driver์™€ Signal์„ ๊ตฌ๋…ํ•˜๊ฒŒ ๋˜๋ฉด ๋‹ค์Œ๊ณผ ๊ฐ™์ด replay ํ•ฉ๋‹ˆ๋‹ค. PublishRelay์™€ BehaviorRelay๊ณผ ๊ฐ™์ด Signal์€ ๊ตฌ๋… ์ดํ›„์˜ ์ด๋ฒคํŠธ๋ฅผ ๋ฐฉ์ถœํ•˜๊ณ  Driver์€ ๊ตฌ๋…์„ ํ•˜๋ฉด ๊ฐ€์žฅ ์ตœ๊ทผ์˜ ์ด๋ฒคํŠธ๋ฅผ ๋ฐฉ์ถœํ•œ๋‹ค๋Š” ์ ์—์„œ ์ฐจ์ด์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. ControlProperty UI Element์˜ property๋ฅผ ๋‚˜ํƒ€๋‚ด๊ธฐ ์œ„ํ•œ Trait ํŠน์ง• ์‹คํŒจํ•˜์ง€ ์•Š๋Š”๋‹ค. share(replay: 1) ์ฒ˜๋Ÿผ ํ–‰๋™ํ•œ๋‹ค - stateful, subscribe ํ˜ธ์ถœ ์‹œ .. 2022. 3. 21.
[RxSwift] Driver๋ž€ ? (feat. bind) observable์„ ์ƒ์„ฑํ•˜๊ณ  ๊ตฌ๋… ํ•  ๋•Œ ๊ฐ€๋” subscribe ๋Œ€์‹  asDriver(), drive()๋กœ ๋ฐ›๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค .. ๋ญ์ง€ ?? ํ•˜๋ฉด์„œ ์žŠ๊ณ  ์‚ด๋˜ ์ค‘ traits ๊ด€๋ จ ๋ฌธ์„œ๋ฅผ ์ฝ๊ณ  driver๊ฐ€ ์žˆ์–ด ์ •๋ฆฌ ํ•ด๋ณด๋ ค๊ตฌ ํ•ฉ๋‹ˆ๋‹ค ! ์ฐธ๊ณ  ๋ฌธ์„œ : https://github.com/ReactiveX/RxSwift/blob/main/Documentation/Traits.md#driver GitHub - ReactiveX/RxSwift: Reactive Programming in Swift Reactive Programming in Swift. Contribute to ReactiveX/RxSwift development by creating an account on GitHub. github.co.. 2022. 3. 21.
[RxSwift] Traits ์ด๋ž€ Single, Maybe, Completable๋ผ๋Š” ์„ธ ๊ฐ€์ง€ Trait์ด ์žˆ์Šต๋‹ˆ๋‹ค. Single Observable์˜ ๋ณ€ํ˜•์œผ๋กœ ์ผ๋ จ์˜ ์š”์†Œ๋ฅผ ๋ฐฉ์ถœํ•˜๋Š”๋Œ€์‹  ํ•ญ์ƒ ๋‹จ์ผ ์š”์†Œ ๋˜๋Š” ์˜ค๋ฅ˜๋ฅผ ๋ฐฉ์ถœํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. Single์„ ์‚ฌ์šฉํ•˜๋Š” ์ผ๋ฐ˜์ ์ธ ์˜ˆ๋Š” URLSession์— response๋กœ์˜ .success, .error์„ ๋ฐฉ์ถœํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋ฉ๋‹ˆ๋‹ค. Single ์ƒ์„ฑํ•˜๊ธฐ func getRepo(_ repo: String) -> Single { return Single.create { single in let task = URLSession.shared.dataTask(with: URL(string: "https://api.github.com/repos/\(repo)")!) { data, _, error in if let.. 2022. 3. 19.
[RxSwift] Disposable DisposeBag ์ด๋ž€ ์ด๋ฒˆ์‹œ๊ฐ„์—๋Š” disposable์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•ด๋ณผ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋งค๋ฒˆ subscribe ํ•ด์ฃผ๊ณ  dispose(by: disposeBag)์— ๋‹ด์•„์ฃผ๋Š”๋ฐ์š” ์—ฌ๊ธฐ์„œ onDisposed๋Š” Observable์ด ๋ฉ”๋ชจ๋ฆฌ์—์„œ ํ•ด์ œ๋˜๋ฉด์„œ ํ˜ธ์ถœ๋˜์–ด ์ง‘๋‹ˆ๋‹ค. Observable์ด onNext -> error ํ˜น์€ completed ์ด๋ฒคํŠธ๋ฅผ ํ˜ธ์ถœํ•˜๊ณ  ์ข…๋ฃŒ๋˜๋ฉด ๋ฆฌ์†Œ์Šค๋ฅผ ๊ด€๋ฆฌํ•ด ์ค„ ํ•„์š” ์—†์ด ์ •์ƒ์ ์œผ๋กœ ๋ฉ”๋ชจ๋ฆฌ๊ฐ€ ํ•ด์ œ ๋˜์ง€๋งŒ Rxswift ๊ณต์‹ ๊ฐ€์ด๋“œ๋ผ์ธ์„ ๋ณด๋ฉด ์ด ๊ฒฝ์šฐ์—๋„ ๋ฆฌ์†Œ์Šค๋ฅผ ์ •๋ฆฌํ•˜๋Š” ๊ฒƒ์„ ๊ถŒ๊ณ  ํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋•Œ Disposable ํƒ€์ž…์„ ๋ชจ๋‘ ๋ชจ์•„ ํ•œ๋ฒˆ์— ํ•ด์ œํ•  ์ˆ˜ ์žˆ๊ฒŒ๋” ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด DisposeBag์„ ์ด์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. subscribe์˜ ์›ํ˜•์ธ๋ฐ์š”. ๋ฆฌํ„ด ํƒ€์ž…์œผ๋กœ Disposable์„ ๋ฐ˜ํ™˜ํ•˜๋Š”๋ฐ ์ด๊ฒƒ๋“ค์„ Disp.. 2022. 3. 17.
[Swift] CustomStringConvertible CustomStringConvertible ์ธ์Šคํ„ด์Šค๋ฅผ ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ ์ปค์Šคํ…€ํ•˜๊ฒŒ ๋ณ€ํ™˜ํ• ์ˆ˜ ์žˆ๋Š” ํ”„๋กœํ† ์ฝœ์ด๋‹ค. struct Point { let x: Int, y: Int } let p = Point(x: 21, y: 30) print(p) // Prints "Point(x: 21, y: 30)" ๊ธฐ๋ณธ Point ๊ตฌ์กฐ์ฒด๋ฅผ ์ถœ๋ ฅํ• ๋•Œ ๊ธฐ๋ณธ ์ถœ๋ ฅ๊ฐ’์œผ๋กœ ๋‚˜์˜ค์ง€๋งŒ CustomStringConvertible ๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ์•„๋ž˜ description์„ ์ค€์ˆ˜ํ•ด์•ผ ํ•˜๋ฉฐ extension Point: CustomStringConvertible { var description: String { return "(\(x), \(y))" } } print(p) // Prints "(21, 30)" ์›ํ•˜๋Š” ์ถœ๋ ฅ๊ฐ’์œผ๋กœ ๋ณ€ํ˜•ํ•˜์—ฌ ์ถœ๋ ฅ.. 2022. 3. 7.
[RxSwift] Combine Operator(CombineLatest, Merge, StartWith, Concat, Zip, WithLastFrom, Sample, SwitchLatest, Debounce) rxSwift์— ๋Œ€ํ•œ ๊ฐ•์˜๋ฅผ ๋“ฃ๋‹ค๊ฐ€ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š” operator์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด ๋†“์œผ๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ค๋”๋ผ๊ตฌ์š” ๊ทธ๋ž˜์„œ ์˜ค๋Š˜์€ ์œ ์šฉํ•˜๊ฒŒ ์‚ฌ์šฉ๋˜๋Š” operator๋“ค์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ๊ณ„์† operator์— ๊ด€ํ•ด ์‚ฌ์šฉํ• ๋•Œ๋งˆ๋‹ค ์—ฌ๊ธฐ์— ์ •๋ฆฌํ•ด ๋†“์„๋ ค๊ตฌ์š” ! Combine ์„œ๋กœ ๋‹ค๋ฅธ ์ŠคํŠธ๋ฆผ์„ ํ•˜๋‚˜์˜ ์ŠคํŠธ๋ฆผ์œผ๋กœ ํ•ฉ์น ๋•Œ ์‚ฌ์šฉํ•˜๋Š” operator CombineLatest ๋‘ observable์—์„œ ์•„์ดํ…œ์„ ๋ฐฉ์ถœํ• ๋•Œ ๊ฐ€์žฅ ์ตœ์‹ ์˜ ์•„์ดํ…œ์„ ๊ฒฐํ•ฉํ•˜๊ณ , ๊ฒฐํ•ฉ๋œ ์•„์ดํ…œ์„ ๋ฐœํ–‰ let left = PublishSubject() let right = PublishSubject() let observable = Observable.combineLatest(left, right, resultSelector: { .. 2022. 3. 6.
[์•„ํ‚คํ…์ณ] MVP ๋ž€ ์˜ค๋Š˜์€ MVx ํŒจํ„ด ์ค‘ MVP ํŒจํ„ด์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋ ค๊ตฌ ํ•œ๋‹ค!! ์ „์— ์žˆ๋˜ ํŒ€์—์„œ MVP ํŒจํ„ด์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ฐœ๋ฐœ ์ค‘์ด์—ˆ๋Š”๋ฐ ์ด๋•Œ ViewController ๋ง๊ณ  Presenter ํŒŒ์ผ์„ ํ•˜๋‚˜ ๋” ๋งŒ๋“ค์–ด ํŒŒ์ผ์ด ์ •๋ง ๋งŽ์•˜์—ˆ๋˜ ๊ฒฝํ—˜์— ์ด์–ด MVP ํŒจํ„ด์— ๋Œ€ํ•ด ์ •๋ฆฌํ•˜๊ณ ์ž ํ•œ๋‹ค. MVP ํŒจํ„ด Model, View, Presenter 3๊ฐ€์ง€๋กœ ์ด๋ฃจ์–ด์ง„ ํŒจํ„ด์ด๋‹ค. MVC ํŒจํ„ด๊ณผ ๋‹ค๋ฅด๊ฒŒ Presenter์˜ ๊ฐœ๋…์„ ๊ฐ€์ง€๊ณ  ์žˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ MVC ํŒจํ„ด์„ ํ™œ์šฉํ•ด ๊ฐœ๋ฐœ์„ ํ•˜๋‹ค๋ณด๋ฉด Controller๊ฐ€ View์™€ ๋ฐ€์ ‘ํ•˜๊ฒŒ ์—ฐ๊ด€๋˜์–ด View+Controller ์˜ ๊ผด๋กœ ํ•ฉํ•˜์—ฌ ๊ฐœ๋ฐœ๋˜๋Š” ๊ฒฝํ–ฅ์ด ์žˆ๋‹ค. ViewController๊ฐ€ ์ง€๋‹Œ ์ƒ๋ช…์ฃผ๊ธฐ ์—ญ์‹œ ๊ณ ๋ คํ•ด์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๋Œ€๊ทœ๋ชจ ํ”„๋กœ์ ํŠธ์— ์žˆ์–ด Controller๊ฐ€ ๋”์šฑ์ด ๋น„๋Œ€ํ•ด์ง„๋‹ค. .. 2022. 1. 6.
[์•„ํ‚คํ…์ณ] MVVM (clean-architecture) ์ด๋ž€ ์˜ค๋Š˜์€ ๊ฐ€์žฅ ๋งŽ์ด ์“ฐ์ด๋Š” MVVM ํŒจํ„ด์— ๋Œ€ํ•ด ๋‹ค์‹œ ์ •๋ฆฌ๋ฅผ ํ•ด๋ณด๋ ค๊ตฌ ํ•œ๋‹ค. ๊ธฐ์กด MVC ํŒจํ„ด์ด View์™€ Controller ๊ฐ„ ๋ถ„๋ฆฌ๊ฐ€ ๋˜์ง€ ์•Š์•„ ๋น„๋Œ€ํ•ด์ง„๋‹ค๋Š” ๋ฌธ์ œ์ ์ด ์žˆ์—ˆ๋‹ค. MVVM ํŒจํ„ด์€ view, view model, model ์ด๋ ‡๊ฒŒ 3๊ฐ€์ง€ ๋ถ„๋ฆฌ๋ฅผ ํ†ตํ•ด ๊ทธ ๋ฌธ์ œ์ ์„ ํ•ด๊ฒฐํ•œ๋‹ค ์•ž์œผ๋กœ๋Š” model์˜ ๋ณ€ํ™”๋ฅผ view model์ด ์ฑ…์ž„์ง€๊ณ  view๋Š” model๊ฐ€ ์ง์ ‘์ ์ธ ์—ฐ๊ฒฐ ์—†์ด view model์„ ํ†ตํ•ด view ์ž์‹ ์„ ์—…๋ฐ์ดํŠธ ํ•œ๋‹ค. ์—ฌ๊ธฐ๊นŒ์ง€๋Š” ๋‚ด๊ฐ€ ์•Œ๊ณ  ์žˆ๋˜ MVVM ํŒจํ„ด์ด์—ˆ๊ตฌ MVVM ํŒจํ„ด์— Repository ?? ๋ฅผ ์“ฐ๋Š” ๊ฒฝ์šฐ๋ฅผ ๋ฐœ๊ฒฌํ•ด์„œ ๊ถ๊ธˆํ•ด์„œ ์ •๋ฆฌ ํ•ด๋ณด๋ ค๊ณ  ๋งˆ์Œ ๋จน๊ฒŒ ๋˜์—ˆ๋‹ค. ์•„๋ž˜ ๊นƒํ—™์„ ์ฐธ๊ณ ํ•˜์—ฌ ์ •๋ฆฌํ•ด๋ณด๋ ค๊ตฌ ํ•œ๋‹ค. https://github.com/kudoleh/iOS-Clean-Ar.. 2021. 12. 22.
[์•„ํ‚คํ…์ณ] Viper ๋ž€ ์š”์ฆ˜ mvvm ํŒจํ„ด์ด ๋ฌด์—‡์ธ์ง€ ์•Œ๊ณ  ๋‚˜๋‹ˆ๊นŒ๋Š” ๋˜ ๋‹ค๋ฅธ ์•„ํ‚คํ…์ณ๋Š” ์—†๋‚˜ ๋งˆ๊ตฌ ๊นƒํ—™์„ ์ฐพ์•„๋ณด๋Š” ์ค‘์ด๋‹ค ์ž ๊น ์—ฌ์œ ๊ฐ€ ์ƒ๊ฒจ์„œ (๊ณง ๊ธฐ๋ง๊ณ ์‚ฌ + ๊ณผ์ œ + ํ…์Šค ์…ค .. ํฌํ ) viper ์•„ํ‚คํ…์ณ์— ๋Œ€ํ•ด ์ •๋ฆฌํ•ด๋ณด๋ ค๊ตฌ ํ•œ๋‹ค !! viper ์•„ํ‚คํ…์ณ๋Š” ์ดˆ๋ฉด์€ ์•„๋‹ˆ๋‹ค ๊ทธ๋ ‡๋‹ค๊ณ  ๊ตฌ๋ฉด๋„ ์•„๋‹ˆ์ง€๋งŒ์€ ํ•˜ํ•˜ ์š”๊ฑธ ๊นƒํ—™ ์Šคํƒ€์— ์ฐœํ•ด๋‘”๊ฒŒ ์ƒ๊ฐ๋‚˜์„œ ํŒจํ„ด์„ ์กฐ๊ธˆ ์‚ดํŽด๋ณด๊ณ  ์˜ˆ์ œ๋กœ๋„ ์‹ค์Šตํ•ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค. https://github.com/MindorksOpenSource/iOS-Viper-Architecture GitHub - MindorksOpenSource/iOS-Viper-Architecture: This repository contains a detailed sample app that implements VIPER archite T.. 2021. 11. 29.
[RxSwift] 2. Subject์™€ Relay ์˜ค๋Š˜์€ subject๋ž€ ๋ฌด์—‡์ธ์ง€์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค subject๋Š” observable๊ณผ observer์˜ ์—ญํ• ์„ ๋ชจ๋‘ ์ˆ˜ํ–‰ํ•˜๋Š” bridge/proxy์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‹ˆ๊นŒ๋Š” ๋ฐ์ดํ„ฐ๋ฅผ ๋„ฃ์–ด์ค„์ˆ˜๋„(onNext), subscribe ํ• ์ˆ˜๋„ ์žˆ๋‹ค๋Š” ๊ฑฐ์ฃ  ! observer์ฒ˜๋Ÿผ subscribeํ•  ์ˆ˜ ์žˆ์ง€๋งŒ subject๋Š” ์—ฌ๋Ÿฌ observer ๊ตฌ๋… ๊ฐ€๋Šฅํ•œ multicast ์ด๊ณ  observable๋Š” ํ•˜๋‚˜์˜ observer๋งŒ ๊ฐ€๋Šฅํ•œ unitcast์ž…๋‹ˆ๋‹ค. unicast์™€ multicast๋Š” ์–ด๋–ค ์ฐจ์ด๊ฐ€ ์žˆ์„๊นŒ์š” ? ์ผ๋ฐ˜์ ์ธ Observable์€ ์–ด๋– ํ•œ ์ƒํƒœ๋„ ๊ฐ€์ง€์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ๋ชจ๋“  Observer๊ฐ€ ๊ตฌ๋…ํ•˜๊ฒŒ ๋˜๋ฉด ๊ทธ๋•Œ๋งˆ๋‹ค ์ƒˆ๋กœ ์ƒ์„ฑ(create)ํ•˜์—ฌ ๋ฐœํ–‰ํ•˜๋Š” ๊ณผ์ •์„ ๊ฑฐ์น˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. let randomNum.. 2021. 11. 20.
[RxSwift ] 1. Observable์ด๋ž€ RxSwift์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•˜๋ ค๊ณ  ๋ณด๋‹ˆ ์ˆจ์ด ํ„ฑํ„ฑ ๋ง‰ํžˆ๋Š” ๊ฑฐ ๊ฐ™์•„์„œ ๊ฐœ๋…์„ ํ์–ด ๋ณด๋Š”๊ฑฐ ๋ง๊ณ  ๋‚ด ๋‚˜๋ฆ„๋Œ€๋กœ ์ •๋ฆฌํ•ด์•ผ๊ฒ ๋‹ค๋Š” ํ•„์š”์„ฑ์„ ๋Š๊ผˆ๋‹ค ..! ๊ทธ๋ž˜์„œ ์˜ค๋Š˜๋ถ€ํ„ฐ TIL ์‹์œผ๋กœ ํ•˜๋‚˜ ํ•˜๋‚˜์”ฉ ๋ฝ€๊ฐœ๋ณด๋ ค๊ณ  ํ•œ๋‹ค ์ฐจ์ฐจ ๊ตต์€ ๋ผˆ๋Œ€๋ถ€ํ„ฐ ์žก๊ณ  ์„ธ์„ธํ•˜๊ฒŒ ๋งˆ์Šคํ„ฐ ํ•˜๋Š” ๊ฒƒ์ด ๋ชฉํ‘œ๋‹ค RxSwift(์•Œ์Šค)์•ผ ์นœํ•ด์ง€์ž์•„ ๐Ÿฐ๐Ÿต๐Ÿฆ„ ๊ทธ๋ž˜์„œ ์˜ค๋Š˜์€ ์ฒซ๋ฒˆ์งธ๋กœ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฐœ๋… Observable์— ๋Œ€ํ•ด ์‚ดํŽด๋ณผ๊ฒƒ์ด๋‹ค ์กฐ๊ธˆ์”ฉ ๋” ์•Œ๊ฒŒ ๋˜๋ฉด์€ ์ถ”๊ฐ€ํ•  ์˜ˆ์ •์ด๋‹ค ์ฐธ๊ณ ํ•œ ๊ธ€์€ ๊ณต์‹ docs๋ฅผ ์ฐธ๊ณ ํ•˜์˜€๋‹ค http://reactivex.io/documentation/observable.html ReactiveX - Observable Observable In ReactiveX an observer subscribes to an Observable. The.. 2021. 11. 15.
[์•„ํ‚คํ…์ณ] RiBs tutorial1 ๋”ฐ๋ผํ•˜๊ธฐ RIBs๋ž€ ์šฐ๋ฒ„์—์„œ ๋งŒ๋“  cross ์•„ํ‚คํ…์ณ ํŒจํ„ด์ด๋ผ๊ณ  ํ•ฉ๋‹ˆ๋‹ค https://github.com/uber/RIBs GitHub - uber/RIBs: Uber's cross-platform mobile architecture framework. Uber's cross-platform mobile architecture framework. - GitHub - uber/RIBs: Uber's cross-platform mobile architecture framework. github.com rib ์ด๋ฆ„์—์„œ ์•Œ ์ˆ˜ ์žˆ๋“ฏ์ด router, interactor, builder ์ด ์„ธ๊ฐ€์ง€๊ฐ€ ํ•ต์‹ฌ์ด๊ตฌ ์ด๋“ค์„ ์ฐจ์ฐจ ์‚ดํŽด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค ! ๊ทธ์ค‘ ์˜ค๋Š˜์€ tutorial1์„ ์šฐ๋ฒ„์—์„œ ์ œ๊ณตํ•œ wiki์™€ ํ•จ๊ป˜ ์ž์„ธํžˆ ๋”ฐ๋ผ ํ•ด.. 2021. 11. 13.
[iOS/swift] ์œ ์šฉํ•œ ์‚ฌ์ดํŠธ ์ •๋ฆฌ ๋ชจ์Œ.zip ์•„๋‹ˆ ๋งค๋ฒˆ ํ•„์š”ํ•œ ๊ธฐ๋Šฅ์„ ๊ตฌ๊ธ€์— ์ณ์„œ ๊นƒํ—ˆ๋ธŒ์— ์ •๋ฆฌ๋œ ํ”„๋ ˆ์ž„์›Œํฌ, ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋งŒ ์‚ฌ์šฉํ–ˆ์—ˆ๋Š”๋ฐ ์ด๋Ÿฐ๊ฑธ ๋ชจ์•„๋†“๋Š” ์‚ฌ์ดํŠธ๊ฐ€ ์žˆ๋‹ค๋Š” ์‚ฌ์‹ค์„ ์ฒจ ์•Œ๊ฒŒ ๋˜์—ˆ๋‹ค .. ์‹ ์„ธ๊ณ„๋‹ค!!! ๊ทธ๋ž˜์„œ ์•ž์œผ๋กœ ์ฐธ๊ณ ํ•  ์‚ฌ์ดํŠธ ๊ธฐ์–ตํ•ด ๋‘๊ธฐ ์œ„ํ•ด ์ด๊ณณ์— ๋‹ค ์ •๋ฆฌํ•ด๋‘๋ คํ•œ๋‹ค ์ถ”ํ›„์— ๊ณ„์† ์—…๋ฐ์ดํŠธ ํ•  ์˜ˆ์ • !! Cocoa controls - www.cocoacontrols.com/ Custom Controls for iOS, iPadOS, macOS, tvOS, and watchOS - Cocoa Controls Is this hosted on GitHub? If this control is hosted on GitHub, paste the address below, otherwise click "Not Hosted on GitHub". Gi.. 2021. 7. 3.
[iOS] Codable - Encodable & Decodable ํ”„๋กœํ† ์ฝœ json์„ ํŒŒ์‹ฑํ•˜๋Š” ๋ฐฉ๋ฒ• ์ค‘ ํ•˜๋‚˜์ด๋‹ค. ๋‹ค๋ฅธ ํ•˜๋‚˜๋Š” ๋‹ค์Œ ๊ธ€์—์„œ ์•Œ์•„๋ณด๊ฒ ๋‹ค. (๋งŽ๊ด€๋ถ€) Codable ์ด๋ž€? -> ์ž์‹ ์„ ๋ณ€ํ™˜ํ•˜๊ฑฐ๋‚˜ ์™ธ๋ถ€ ํ‘œํ˜„(ex> json)์œผ๋กœ ๋ณ€ํ™˜ํ• ์ˆ˜ ์žˆ๋Š” ํƒ€์ž… ๋ณดํ†ต์€ json์œผ๋กœ ๊ฐ€์žฅ ๋งŽ์ด ์‚ฌ์šฉ๋œ๋‹ค! ๊ทธ๋ž˜์„œ ์•„๋ž˜ ์˜ˆ์‹œ๋„ json ํƒ€์ž…์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ์‚ดํŽด๋ณผ ๊ฒƒ์ด๋‹ค. Encodable๊ณผ Decodable์„ ํ†ตํ‹€์€ ๊ฒƒ typealias๋Š” ๋ญ์ง€ ?? * typealias - ๊ธฐ์กด ์„ ์–ธ๋œ ๋ฐ์ดํ„ฐ ํƒ€์ž…์— ๋ณ„์นญ์„ ์‚ฌ์šฉํ•จ์œผ๋กœ์„œ ์ฝ”๋“œ๋ฅผ ๋” ์ฝ๊ธฐ ์‰ฝ๋„๋ก ๋งŒ๋“œ๋Š” ๋ฌธ๋ฒ• ์˜ˆ๋ฅผ ๋“ค์–ด์„œ typealias Name: String ์ด๋ผ ํ–ˆ์„ ๋•Œ let name: Name = "ํ™๊ธธ๋™" == let name: String = "ํ™๊ธธ๋™" ๊ธฐ์กด ํƒ€์ž… String์˜ ๋ณ„๋ช…์„ Name์œผ๋กœ ํ–ˆ์„๋•Œ ์•„ํ•˜ String .. 2021. 5. 31.
[iOS] View Controller ์ƒ๋ช…์ฃผ๊ธฐ ๋ทฐ ์ปจํŠธ๋กค๋Ÿฌ๋Š” ๋ฐ์ดํ„ฐ ๊ฐ์ฒด์™€ ๋ทฐ ์‚ฌ์ด์˜ ์ค‘๊ฐœ์ž์ด๋‹ค. โ— method viewDidLoad() - ๋ทฐ๋ฅผ ๋ฉ”๋ชจ๋ฆฌ์— ๋กœ๋“œ ํ•œ ํ›„ ์ˆ˜ํ–‰, ๋ทฐ์˜ ์ดˆ๊ธฐํ™” ์ž‘์—… viewWillAppear() - will : ํ™”๋ฉด์— ํ‘œ์‹œ๋˜๊ธฐ ์ง์ „ ํ˜ธ์ถœ - ๋ทฐ๊ฐ€ ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚  ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์„œ๋“œ viewDidAppear() - did : ํ™”๋ฉด์ด ํ‘œ์‹œ๋œ ์งํ›„ ํ˜ธ์ถœ viewWillDisappear() - ๋ทฐ๊ฐ€ ํ™”๋ฉด์—์„œ ์‚ฌ๋ผ์งˆ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์„œ๋“œ viewDidDisappear() - ๋ทฐ๊ฐ€ ํ™”๋ฉด์—์„œ ์™„์ „ํžˆ ์‚ฌ๋ผ์กŒ์„ ๋•Œ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์„œ๋“œ โ—์ƒ๋ช… ์ฃผ๊ธฐ(life cycle) viewDidLoad ↓ viewWillAppear ↓ viewDidAppear ↓ viewWillDisappear ↓ viewDidDisappear ↓ viewDidUnload.. 2021. 5. 3.
[iOS] Layout ์ •๋ฆฌ layout Frame ๊ธฐ๋ฐ˜ ๋ชจ๋“  ๋ทฐ์˜ ์œ„์น˜๋ฅผ ์„ค์ •ํ•ด์ฃผ๋Š” ๋ฐฉ์‹, ๊ฐ€์žฅ ์œ ์—ฐํ•˜๊ณ  ๋น ๋ฅธ ์„ฑ๋Šฅ์„ ๋ณด์ธ๋‹ค. auto layout ๊ธฐ๋ฐ˜ View๋“ค ๊ฐ„์˜ ๊ด€๊ณ„๋ฅผ ์ด์šฉํ•˜์—ฌ View์˜ ์œ„์น˜์™€ ํฌ๊ธฐ๋ฅผ ๋™์ ์œผ๋กœ ๊ณ„์‚ฐํ•˜๋Š” Layout System ์™ธ๋ถ€ ๋ณ€๊ฒฝ : super view์˜ ํฌ๊ธฐ๋‚˜ ๋ชจ์–‘์ด ๋ณ€๊ฒฝ๋ ๋•Œ (ex> ํšŒ์ „, ๋ถ„ํ•  ๋ทฐ) ๋‚ด๋ถ€ ๋ณ€๊ฒฝ : ์ธํ„ฐํŽ˜์ด์Šค ๋ทฐ์˜ ํฌ๊ธฐ๋‚˜ ์„ค์ •์ด ๋ณ€๊ฒฝ๋ ๋•Œ ๋ฐœ์ƒ ์Šคํ† ๋ฆฌ ๋ณด๋“œ์ƒ layout์— ๋Œ€ํ•ด ์‚ดํŽด๋ณด์ž Attrubuote ์ข…๋ฅ˜์—๋Š” ์ด๋ ‡๊ฒŒ 4๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค. layout์˜ ๊ณ„์‚ฐ๋˜๋Š” ์„ ํ˜• ๋ฐฉ์ •์‹ ์€ ์ด๋Ÿฌํ•˜๋‹ค ๊ทธ๋ž˜์„œ ๋งค๋ฒˆ ์Šคํ† ๋ฆฌ ๋ณด๋“œ ์™ผ์ชฝ์— ์ด๋Ÿฌํ•œ ๋ฐฉ์ •์‹์„ ๋ณผ ์ˆ˜ ์žˆ๋Š”๋ฐ ์ด๊ฒƒ์ด ๋ฐ”๋กœ ๊ทธ๊ฒƒ์ด๋‹ค !! ๊ทธ๋Ÿฌ๋ฉด safeArea์™€ view๋Š” ๋ญ๊ฐ€ ๋‹ค๋ฅผ๊ฑธ๊นŒ๋‚˜ ์• ํ”Œ์€ safeArea๋ฐ–์— ui ๋ฐฐ์น˜์‹œํ‚ค์ง€ ๋ง๊ฒƒ์„ ๊ถŒ๊ณ ํ–ˆ.. 2021. 4. 27.