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

    GitHub adds AI-powered bug detection to expand security coverage

    March 26, 2026

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

    March 26, 2026

    Maryland lawmakers advance gambling bills targeting sweepstakes and college prop bets

    March 25, 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

    Where should I put http basic auth delegate methods, which are shared among a couple of view controllers?

    March 25, 2026

    swiftui – How to show/hide iOS toolbar buttons with fancy Liquid Glass animation?

    March 24, 2026

    ios – Unwanted Communication Reporting Extension deletes messages always

    March 23, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    GitHub adds AI-powered bug detection to expand security coverage

    March 26, 2026

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

    March 26, 2026

    Maryland lawmakers advance gambling bills targeting sweepstakes and college prop bets

    March 25, 2026

    Spotting and Avoiding ROT in Your Agentic AI – O’Reilly

    March 25, 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!

    GitHub adds AI-powered bug detection to expand security coverage

    March 26, 2026

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

    March 26, 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.