Get up to 80 % extra points for free! More info:

Lesson 9 - iOS ToDo app in Swift - Filling in and serialization

In the previous lesson, Creating an iOS ToDo app storing data, we started building a ToDo app.

For today's iOS tutorial, I promised to finish marking tasks as completed and saving data.

Marking tasks as completed

Let's program marking tasks as completed first. We've already prepared a method which is called when the user selects a TableView row. We'll use the accessoryType cell property and set it to .checkmark or .none when the row is selected:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    if let selectedCell = tableView.cellForRow(at: indexPath) {
        if selectedCell.accessoryType == .checkmark {
            selectedCell.accessoryType = .none
        } else {
            selectedCell.accessoryType = .checkmark
        }
    }
}

If we now select a row, it'll be marked as completed or uncompleted. That's because we set the accessoryType to .none if it's already set to .checkmark.

Bug hunt

It looks like we're done. However, there's a very essential error


 

...End of the preview...
Continue further

You will gain knowledge worth hundreds of thousands for a few crowns

You've come here and that's great! We believe that the first lessons showed you something new and useful
Do you want to continue the course? Go to the premium section.

Buy this course

Buy all currently available lessons with exercise submitting and other features for just $9
Current account balance $0
By buying this package, you'll have access to all 16 articles (16 lessons) in this course.

Before buying this article, you have to buy the previous one

This article is licensed: Premium, by buying this article, you agree with the terms of use.

What will you get from us in the next lessons?
  • Unlimited and permanent access to individual lessons.
  • High quality IT knowledge.
  • Skills to help you get your dream and well-paid job.

Article description

Requested article covers this content:

In this Swift tutorial, we'll fill our ToDo app with tasks and have a look at serialization/deserialization of data into/from a file.

You gain credits by supporting our network. This is done by sending a helpful amount of money to support the site, or by creating content for the network.

Article has been written for you by Filip Němeček
Avatar
Activities