Yorkie

ExamplesTodoMVC iOS

TodoMVC iOS

This is an example of real-time collaborative TodoMVC using Yorkie iOS SDK.

    TodomvcApp.swift
    1/*
    2 * Copyright 2025 The Yorkie Authors. All rights reserved.
    3 *
    4 * Licensed under the Apache License, Version 2.0 (the "License");
    5 * you may not use this file except in compliance with the License.
    6 * You may obtain a copy of the License at
    7 *
    8 * http://www.apache.org/licenses/LICENSE-2.0
    9 *
    10 * Unless required by applicable law or agreed to in writing, software
    11 * distributed under the License is distributed on an "AS IS" BASIS,
    12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13 * See the License for the specific language governing permissions and
    14 * limitations under the License.
    15 */
    16
    17import SwiftUI
    18
    19@main
    20struct TodomvcApp: App {
    21 @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
    22 @Environment(\.scenePhase) var scenePhase
    23
    24 @State var key = Constant.documentKey
    25
    26 var body: some Scene {
    27 WindowGroup {
    28 NavigationView {
    29 VStack {
    30 Text("Input document key or use the default")
    31 TextField(text: self.$key) {
    32 Text("Input documentKey")
    33 }
    34
    35 NavigationLink(destination: ContentView()) {
    36 Text("Go")
    37 }
    38 }
    39 .padding()
    40 }
    41 .navigationViewStyle(.stack)
    42 }.onChange(of: self.scenePhase) { newPhase in
    43 Log.log("[ChangePhase] -> \(newPhase)", level: .debug)
    44 }
    45 .onChange(of: self.key) { newValue in
    46 Constant.documentKey = newValue
    47 }
    48 }
    49}
    50
    51final class AppDelegate: NSObject, UIApplicationDelegate {
    52 func application(
    53 _: UIApplication,
    54 didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil
    55 ) -> Bool {
    56 return true
    57 }
    58}
    GitHub
    Your browser does not support the video tag.