Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    What is quantum computing? 10 terms everyone should know

    April 13, 2026

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    A simpler path to unified, AI-ready network operations

    April 12, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»ios – when I restart iPhone my tasks and notes in my app is disappeared
    iOS Development

    ios – when I restart iPhone my tasks and notes in my app is disappeared

    big tee tech hubBy big tee tech hubMarch 26, 2026003 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    ios – when I restart iPhone my tasks and notes in my app is disappeared
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    my app have some issues: when I restart iPhone my tasks and notes in app is disappeared. same situation when I update new version of my app. my app has synchronization via iCloud through all Apple devices (iPad, Mac, iPhone)

    my app is distributing in App Store:

    below code of my app, tell me please some ways to do for get 100% right syntonization via iCloud without bugs and missing content:

    ContentView.swift:

    import SwiftUI
    
    struct ContentView: View {
        @State private var currentTodo = ""
        @State private var currentNoteContent = ""
        @State private var expandedTaskId: UUID?
        @State private var isShowingNotes = false
        @State private var showingAlert = false
        @State private var alertMessage = ""
        
        @StateObject private var taskManager = TaskManager()
        
        // Добавление задачи
        private func addTodoAction() {
            guard !currentTodo.trimmingCharacters(in: .whitespaces).isEmpty else {
                alertMessage = "Введите текст задачи"
                showingAlert = true
                return
            }
            
            taskManager.addTodo(todo: currentTodo.trimmingCharacters(in: .whitespaces))
            currentTodo = ""
        }
        
        var body: some View {
            NavigationStack {
                VStack {
                    // 1. Поле ввода и кнопка
                    HStack {
                        TextField("Write task here and click the right button", text: $currentTodo)
                            .textFieldStyle(RoundedBorderTextFieldStyle())
                            .onSubmit { addTodoAction() }
                        
                        Button(action: addTodoAction) {
                            Image(systemName: "pencil.tip.crop.circle.badge.plus")
                        }
                        .padding(.leading, 5)
                    }
                    .padding()
                    
                    // 2. Список задач
                    List {
                        ForEach($taskManager.todos, id: \.id) { $todo in
                            VStack(alignment: .leading) {
                                HStack(alignment: .center) {
                                    VStack(alignment: .leading, spacing: 4) {
                                        Text(todo.todo)
                                            .lineLimit(1)
                                        
                                        HStack {
                                            Slider(
                                                value: $todo.progress,
                                                in: 0...100,
                                                step: 1
                                            ) { isEditing in
                                                if !isEditing {
                                                    taskManager.updateProgress(for: todo.id, progress: todo.progress)
                                                }
                                            }
                                            .frame(width: 100)
                                            Text("\(Int(todo.progress))%")
                                                .font(.caption)
                                                .foregroundColor(.gray)
                                                .frame(width: 40, alignment: .leading)
                                        }
                                    }
                                    .frame(maxWidth: .infinity, alignment: .leading)
                                    
                                    Button(action: {
                                        todo.subtasks.append(Subtask(title: "New subtask"))
                                        expandedTaskId = todo.id
                                    }) {
                                        Image(systemName: "plus.circle")
                                            .foregroundColor(.blue)
                                    }
                                    .buttonStyle(PlainButtonStyle())
                                    .padding(.leading, 4)
                                    
                                    Button(action: {
                                        expandedTaskId = (expandedTaskId == todo.id) ? nil : todo.id
                                    }) {
                                        Image(systemName: expandedTaskId == todo.id ? "chevron.down" : "chevron.right")
                                            .foregroundColor(.gray)
                                            .imageScale(.medium)
                                    }
                                    .buttonStyle(PlainButtonStyle())
                                    .contentShape(Rectangle())
                                    .frame(width: 24, height: 24)
                                }
                                .padding(.vertical, 6)
                                
                                if expandedTaskId == todo.id && !todo.subtasks.isEmpty {
                                    ForEach($todo.subtasks, id: \.id) { $subtask in
                                        HStack {
                                            Button(action: {
                                                taskManager.toggleSubtaskCompletion(for: todo.id, subtaskId: subtask.id)
                                            }) {
                                                Image(systemName: subtask.isCompleted ? "checkmark.square.fill" : "square")
                                                    .foregroundColor(subtask.isCompleted ? .blue : .gray)
                                            }
                                            .buttonStyle(PlainButtonStyle())
                                            
                                            TextField("Подзадача", text: $subtask.title)
                                                .disabled(subtask.isCompleted)
                                                .foregroundColor(subtask.isCompleted ? .gray : .primary)
                                                .padding(.leading, 4)
                                                .onChange(of: subtask.title) { _ in
                                                    taskManager.scheduleSave()
                                                }
                                        }
                                        .padding(.leading, 28)
                                        .padding(.vertical, 4)
                                    }
                                    .padding(.top, 4)
                                }
                            }
                            .padding(.horizontal, -8)
                        }
                        .onDelete(perform: { offsets in
                            taskManager.deleteTodo(at: offsets)
                        })
                        
                        // 3. Кнопка Notes
                        Button(action: {
                            isShowingNotes = true
                        }) {
                            Text("Notes")
                                .font(.headline)
                                .foregroundColor(.white)
                                .padding()
                                .frame(maxWidth: .infinity)
                                .background(Color.blue)
                                .cornerRadius(10)
                        }
                        .padding(.horizontal)
                        .padding(.top, 10)
                        
                        // 4. Индикатор загрузки
                        if taskManager.isSyncing {
                            ProgressView("Downloading..")
                                .progressViewStyle(CircularProgressViewStyle())
                                .padding()
                        }
                    }
                    .navigationTitle("Just To Do It List")
                }
                    
    .onAppear {
        
        DataManager.shared.ensureTodosFileExists()
        
        DataManager.shared.taskManager = taskManager
        
        DataManager.shared.startMonitoringTodosChanges()
        
        taskManager.loadTodos()
    
        
        // Принудительно перезагружаем заметки при открытии
           DataManager.shared.loadNotes { result in
               switch result {
               case .success(let content):
                   currentNoteContent = content ?? ""
               case .failure(let error):
                   alertMessage = "Error loading notes: \(error.localizedDescription)"
                   showingAlert = true
               }
           }
           
           // Запускаем мониторинг изменений (если ещё не запущен)
            DataManager.shared.startMonitoringNotesChanges()
            DataManager.shared.startMonitoringTodosChanges()
       }
    
    .navigationDestination(isPresented: $isShowingNotes) {
        NotesEditView(
            noteContent: $currentNoteContent,
            onSave: { savedText in
                currentNoteContent = savedText
                DataManager.shared.saveNotes(
                    content: savedText,
                    completion: { error in
                        if let error = error {
                            alertMessage = "Error: \(error.localizedDescription)"
                            showingAlert = true
                        }
                    }
                )
            }
        )
        .onDisappear {
            // Принудительно сохраняем текущие заметки при закрытии
            DataManager.shared.saveNotes(
                content: currentNoteContent,
                completion: { error in
                    if let error = error {
                        alertMessage = "Error via closure: \(error.localizedDescription)"
                        showingAlert = true
                    } else {
                        print("✅ Notes saved via closure")
                    }
                }
            )
            isShowingNotes = false
        }
    }
    



    Source link

    app disappeared iOS iPhone notes restart tasks
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    javascript – React Native iOS app crashes on language change with react-native-restart (works on Android)

    April 12, 2026

    Apple Highlights Photos Shot on iPhone During NASA’s Mission to Moon

    April 12, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    What is quantum computing? 10 terms everyone should know

    April 13, 2026

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    A simpler path to unified, AI-ready network operations

    April 12, 2026

    Launching S3 Files, making S3 buckets accessible as file systems

    April 12, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    What is quantum computing? 10 terms everyone should know

    April 13, 2026

    Firebase App Check debug token returns 403 “App attestation failed” on iOS Flutter app — misleading error hides API key restriction

    April 13, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.