// MARK: - Bulk actions (episode 11)
The PersistenceController is the single source of truth for the data layer. Episode 11 often adds a deleteAllCompleted() helper for bulk‑operations. import SwiftUI import Combine
final class TaskListViewModel: ObservableObject @Published var tasks: [TaskItem] = [] @Published var showAddTaskSheet = false @Published var selection = Set<UUID>() // For multi‑selection
Prepared for developers who are following a “Swift To‑Do List” tutorial series (episode 11) or who want a concise reference for the concepts covered in that stage of the project. | Episode | Core Goal | Typical New Feature Introduced | |---------|-----------|--------------------------------| | 1‑2 | Project scaffolding, UI basics | Simple list using UITableView / List | | 3‑5 | Data persistence basics | UserDefaults , Codable | | 6‑8 | Refactoring & MVVM | View‑model separation, bindings | | 9‑10 | Advanced UI/UX | Swipe actions, drag‑and‑drop reordering | | 11 | Full‑featured persistence & editing | Core Data integration, inline editing, and multi‑selection | swift to-do list 11 crack
private var cancellables = Set<AnyCancellable>() private let context: NSManagedObjectContext
// MARK: - CRUD wrappers
var body: some View HStack Image(systemName: task.isCompleted ? "checkmark.circle.fill" : "circle") .foregroundColor(task.isCompleted ? .green : .secondary) .onTapGesture(perform: toggleAction) // MARK: - Bulk actions (episode 11) The
func deleteSelected() let toDelete = tasks.filter selection.contains($0.id ?? UUID()) toDelete.forEach PersistenceController.shared.delete($0) selection.removeAll()
var onSave: (String, Date?) -> Void
func markSelectedAsCompleted() tasks.filter selection.contains($0.id ?? UUID()) .forEach $0.isCompleted = true PersistenceController.shared.save() | Episode | Core Goal | Typical New
private func save() do try container.viewContext.save() catch // In production you’d present an alert / log let nsError = error as NSError fatalError("Core Data save error: \(nsError), \(nsError.userInfo)")
func addTask(title: String, dueDate: Date? = nil) PersistenceController.shared.addTask(title: title, dueDate: dueDate)
// MARK: - Helper CRUD
func addTask(title: String, dueDate: Date? = nil) let task = TaskItem(context: container.viewContext) task.id = UUID() task.title = title task.isCompleted = false task.creationDate = Date() task.dueDate = dueDate save()
Warning
You are using an outdated browser. Sorry, this web site doesn't support Internet Explorer 6. To get the best possible experience using our website we recommend that you upgrade to a newer version or other web browser. A list of the most popular web browsers can be found below. It is completely free for download: