From the course: Building a Note-Taking App for iOS 11 with Swift

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Set a data source for the table view

Set a data source for the table view

From the course: Building a Note-Taking App for iOS 11 with Swift

Start my 1-month free trial

Set a data source for the table view

- [Instructor] Our next step is to put some data inside of our table view. We're going to get that data from an array. So let's start with creating that array. So right underneath my IBOutlet line of code in my class Viewcontroller.swift, I'm going to create a new instance variable with the var keyboard. We'll call this data. And this is going to be an array of strings. So string, inside of brackets, and then set that equal to an array, so some more brackets and then three strings inside of there. We'll just call 'em Item 1, Item 2, and you guessed it Item 3. So we have this setup. We have our data. And now what we need to do is associate our table with not this data but rather the class that's going to provide the data to the table views. So the class is a UITableView data source. Now, to do that we need to say that our class implements the UITableView data source protocol. And we haven't yet done that. We also have to set the data source property of the table. So let's set the data…

Contents