Thuta Learning
ProjectsProgrammingbeginner

Project: Task Manager App - Part 1 (Setup + Core Structure)

Relax. We'll talk through this in plain words — no textbook voice.

What you'll walk away with

  • Apply Project: Task Manager App - Part 1 (Setup + Core Structure) in a hands-on project
  • Write and run the code yourself
  • Build out an entire project step by step

Let's think about this for a second

In this mini project we'll build a Task Manager app that manages a to-do-style task list. We'll split it into 3 parts, and in Part 1 we'll lay down the data model and core structure first. We'll define a Task struct as a value type holding title, isDone, and priority for each task, and use a Priority enum for priority levels. Since TaskManager needs to hold the task list and handle add/print operations, we'll write it as a class — a reference type. This is hands-on practice directly applying the struct-vs-class and enum topics.

Let's build it

Build a Priority enum with three cases: low, medium, high. Give the Task struct four fields: id (Int), title (String), priority (Priority), isDone (Bool, default false). Build a TaskManager class with a private var tasks: [Task] = [] array, and write an addTask(title:priority:) method that auto-generates the id using tasks.count + 1. Write a printAllTasks() method that formats and prints each task with its id, title, priority, and status. In Part 2, we'll keep building on this TaskManager by adding filter/sort features.

Sample Code

swift
enum Priority: String {
    case low = "Low"
    case medium = "Medium"
    case high = "High"
}

struct Task {
    let id: Int
    var title: String
    var priority: Priority
    var isDone: Bool = false
}

class TaskManager {
    private var tasks: [Task] = []

    func addTask(title: String, priority: Priority) {
        let newTask = Task(id: tasks.count + 1, title: title, priority: priority)
        tasks.append(newTask)
    }

    func printAllTasks() {
        print("----- Task List -----")
        for task in tasks {
            let status = task.isDone ? "Done" : "Pending"
            print("#\(task.id) [\(task.priority.rawValue)] \(task.title) - \(status)")
        }
    }
}

let manager = TaskManager()
manager.addTask(title: "Swift optionals ပြန်ကျက်မယ်", priority: .high)
manager.addTask(title: "Struct vs Class notes ရေးမယ်", priority: .medium)
manager.printAllTasks()
You should see
The console prints a task list header followed by two neatly formatted lines containing id, priority, title, and status.

Give it 5 minutes

Add an urgent case to Priority, add about three tasks with addTask, then call printAllTasks() and check whether the output format is correct. Spend about 5 minutes on it.

One thing to watch out for

Keep the Task struct as a value type — understanding that appending it to an array makes a copy will make writing the update logic in Part 2 much easier.

Easy traps

  • Treating the Task struct like a mutable reference type, the way a class works, and writing var manager: Task without understanding copy semantics
  • Not noticing duplicate ids when assigning id manually (we'll fix this with validation in Part 3)

Try It Yourself

Add an urgent case to Priority, add about three tasks with addTask, then call printAllTasks() and check whether the output format is correct. Spend about 5 minutes on it.

You'll know it worked when: The console prints a task list header followed by two neatly formatted lines containing id, priority, title, and status.

Project: Task Manager App - Part 1 (Setup + Core Structure) | Thuta Learning