Save up to 80 % on our Swift e-learning courses. Only this week!
Get up to 80 % extra points for free! More info
Summer BF

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.

Limited offer: Learn all knowledge and save money

Buy lessons and exercise submitting one by one 100 points
Buy all currently available lessons with exercise submitting and other features for an exclusive price 76 points ($6.84)
Currently, you have 0 points
By buying this exclusive package, you'll have access to all 16 lessons in this course including exercise submitting while saving $2.16. This is a time limited offer for all lessons in this course. Buy it now and gain a limited 24% discount.
You gain 76 points for adding an article to the site, or for $9.00 $6.84
Buy only the lesson 10 points
Currently, you have 0 points
You gain 10 points for adding an article to the site, or for $0.90

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 points 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 (6)