목록Swift/CS (13)
HIT해

ifLet 어디서 많이 보지 않았는가 바로 if let 이랑 비슷한 역할을 한다. 주로 상태가 존재하는 경우에만 특정 뷰의 Modifier를 적용하려고 할때 사용된다.상태의 값이 존재할때만 활성화되고 그렇지 않다면 무시된다. 예시 코드를 보자 1. Reducer@Reducerstruct AlertAndConfirmationDialog { @ObservableState struct State: Equatable { @Presents var alert: AlertState? @Presents var confirmationDialog: ConfirmationDialogState? var count = 0 } enum Action { case alert(PresentationActi..
https://developer.apple.com/documentation/swiftui/view/refreshable(action:) refreshable(action:) | Apple Developer DocumentationMarks this view as refreshable.developer.apple.com nonisolatedfunc refreshable(action: @escaping () async -> Void) -> some View 간단하게 새로고침을 구현할 수 있는 키워드다. 새로고침 UI가 상단에 생성되고 안에 정의한 함수들이 실행된다 사용방법struct RefreshableView: View { let store: StoreOf @State var isLoading = fa..
NavigationStack | Apple Developer DocumentationA view that displays a root view and enables you to present additional views over the root view.developer.apple.com NavigationStack 이란?RootView를 표시하고 RootView 위에 추가 뷰를 표시할수 있는 뷰. iOS 16.0 이상에서 동작한다.@MainActor @preconcurrencystruct NavigationStack where Root : View 공식문서상에 적힌 개요를 확인해보자. 1. 기본 네비게이션 스택NavigationStack을 사용하여 뷰의 스택을 루트 뷰 위에 표시한다. 사용자는 Nav..

store.send().finish() vs store.send()store.send():이 코드는 TCA(Typically Composable Architecture)에서 액션을 스토어로 전송한다.기본적으로 이 메서드는 비동기 작업을 시작하고, 해당 액션이 처리되는 동안의 작업을 관리하지 않는다.store.send().finish():finish()는 send(_:) 메서드가 반환하는 Effect의 메서드.finish()는 해당 액션이 완료되었음을 나타내는 신호를 보낸다finish의 역할비동기 작업의 완료 신호:finish()는 비동기 작업이 완료되었음을 나타내는 신호를 보낸다.비동기 효과가 끝났을 때, 상태를 업데이트하거나 후속 작업을 처리하는 데 사용된다.상태 동기화:액션이 완료된 후, 상태가 올바..

defer란?Swift에서 코드 블록의 마지막에 실행될 코드를 예약할때 사용된다.defer 블록내의 코드는 해당 코드 블록이 종료되기 직전에 실행된다. 자원 해제, 상태 복구, 정리 작업과 같이 코드 블록이 끝날 때 반드시 수행되어야하는 작업을 지정하는데 쓰인다. func exampleFunction() { print("Start") defer { print("Deferred: This will run at the end of the function") } print("End")} 실행결과StartEndDeferred: This will run at the end of the function

소스코드 개요더보기이 화면에서는 \를 사용하여 작은 기능을 사용하여 더 큰 기능으로 구성하는 방법을 보여 줍니다리듀서 빌더와 'Scope' 리듀서, 매장의 'Scope' 오퍼레이터.카운터 화면의 도메인을 재사용하여 두 번 더 큰 도메인에 임베딩합니다 전체 코드@Reducerstruct TwoCounters { @ObservableState struct State: Equatable { var counter5 = Counter.State() var counter2 = Counter.State() } enum Action { case counter1(Counter.Action) case counter2(Counter.Action) } var body: some Reducer ..

전체 소스 코드import ComposableArchitectureimport SwiftUIprivate let readMe = """ This screen demonstrates how changes to application state can drive animations. Because the \ `Store` processes actions sent to it synchronously you can typically perform animations in the \ Composable Architecture just as you would in regular SwiftUI. To animate the changes made to state when an action is sent to th..

https://github.com/pointfreeco/swift-composable-architecture?tab=readme-ov-file#examples GitHub - pointfreeco/swift-composable-architecture: A library for building applications in a consistent and understandable way,A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind. - pointfreeco/swift-composable-architecturegithub.com 해..