전체 글
-
Xcode Tips (With SwiftUI)끄적끄적 2021. 12. 14. 13:52
Simulator toggle darkMode : Command + Shift + A XCode show / hide navigator (좌측 바) : Command + 0 show / hide inspectors (우측 바): Command + Option + 0 show / hide debug area(하단 바): Command + Shift + Y Update Preview (SwiftUI) : Command + Option + p Command + Click (on element in canvas preview ) -> 수정 및 해당 Contents 의 Code 부분 확인 가능.
-
PassthroughSubject VS CurrentValueSubjectSwiftUI/Basic Property Wrappers 2021. 12. 10. 19:29
PassthroughSubject A subject that broadcasts elements to downstream subscribers. Declaration final class PassthroughSubject whereFailure : Error Overview As a concrete implementation of Subject, the PassthroughSubject provides a convenient way to adapt existing imperative code to the Combine model. Unlike CurrentValueSubject, a PassthroughSubject doesn’t have an initial value or a buffer of the ..
-
Combine-Chap7_Sequence OperatorCombine 2021. 12. 10. 18:01
import Foundation import Combine var subscriptions = Set() func example(of name: String, closure: () -> Void) { print("-----------------\(name)----------") closure() } example(of: "hi") { print("hi") } example(of: "min") { let publisher = [1,-50,246,0].publisher publisher .print("publisher") .min() .sink(receiveValue: {print("Lowest value is \($0)")}) .store(in: &subscriptions) } // using own co..
-
Combine_Chap5_CombiningOperatorsCombine 2021. 11. 26. 17:42
import UIKit import Combine var greeting = "Hello, playground" var subscriptions = Set() func example(of name: String, closure: () -> Void) { print("--------------------------\(name)--------------------------") closure() } example(of: "prepend(Output...)") { let publisher = [3,4].publisher publisher .prepend(1,2) .prepend(-1,0) .sink(receiveValue: {print($0)}) .store(in: &subscriptions) } exampl..
-
Assertions & PreconditionsSwift/Swift Language 2021. 11. 24. 18:13
Assertions and Preconditions Assertions 와 precondins 는 runtime 시 일어나는 확인작업이다. 코드를 더 실행하기 전에 필수 조건을 만족하는지 먼저 확인하기 위해 사용한다. 만약 assertion 이나 precondition 의 Boolean condition 이 true 라면 코드는 평상시와 같이 계속 진행된다. 그러나 그렇지 않은 경우, 코드 실행이 종료되고, 앱도 종료된다(terminated). 코딩 도중 본인이 가정하거나 예상하는 것을 확인하기 위해 이것들을 사용할 수 있다. Assertions 는 실수 또는 잘못된 가정을 개발 도중 확인 하는 데에, preconditions 는 production 에서 발생하는 문제들을 찾는 데에 사용할 수 있다. R..
-
Swift Language ) Error HandlingSwift/Swift Language 2021. 11. 23. 16:08
Error handling 은 프로그램 내 error conditions 에 대해 반응하고 recover 하는 과정이다. Swift 는 runtime 시 throwing, catching, propagating, manipulating recoverable erros 에 대해 first-class support 를 제공한다. 어떤 operations 는 실행을 완전히 마칠 수 없을 수 있고, 유용한 output 을 내지 못할 수도 있다. Optionals 는 값이 없음을 나타낼 때 사용된다. An operation 이 fail 될 때, 어떤 것이 failure 을 발생시켰는지 알면 그에 따라 반응할 수 있다. 예를 들어, disk 내에 있는 file 내 data 를 읽고 처리하는 과정에 대해 생각해보자...
-
Combine_Chap2_Publishers&SubscribersCombine 2021. 11. 23. 00:57
이번 챕터에서는, Publishers 와 그것들을 subscribe 하는 여러가지 방법에 대해 실험할 거에요. ((앞으로 자주 테스트에 사용할 코드이니 어떻게 생겼는지만 파악해주세요 :))) public func example(of description: String, action: () -> Void) { print("\n——— Example of:", description, "———") action() } Combine 의 핵심은 Publisher protocol 에 있어요. 이 protocol 은 하나 또는 다중의 subscriber 로 sequence of values 를 보낼 수 있는 타입의 조건들을 정의합니다. 다시 말하면, publisher 는 values 를 포함하는 events 를 보냅니..
-
Combine_Chap4_FilteringOperatorsCombine 2021. 11. 21. 02:08
import UIKit import Combine var subscriptions = Set() func example(of name: String, closure: @escaping () -> Void) { print("-------------------- \(name) --------------------") closure() } example(of: "test") { //1. Create a new publisher, which will emit a finite number of values — 1 through 10, // and then complete, using the publisher property on Sequence types. let numbers = (1 ... 10).publis..