Challenge: Make a Data Source

Make a to-do list application. The user will type a task into the text field. When the user clicks the Add button, you will add the string to an array and the new task will appear at the end of the list (Figure 7.15).

Figure 7.15  Objects in to-do list app

Objects in to-do list app

How will you get the table view to fetch updated information? You tell the table view to reload its data using the aptly-named method reloadData(). The table view will then reload all the cells that the user can see.

You get extra points for making the table view editable.

Get Cocoa Programming for OS X: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.