To-Do List
Part of the Introduction to SwiftUI section of Coddy's Swift journey. Lesson 49 of 50.
Challenge
HardBuild a to-do list with the Todo struct:
- a
TextFieldwith the placeholderNew task(identifierfield) and anAddbutton that appends aTodowith the typed title to atodosstate array (starting empty) and clears the field - a
List(identifierlist) with oneToggleper task, titled with the task and bound to itsdone - a text (identifier
progress) that reads1 of 2 done, counting the tasks whosedoneis true
Try it yourself
import SwiftUI
@main
struct CoddyApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}All lessons in Introduction to SwiftUI
Practice on your own: Swift playground