From the course: Shared Economy for iOS Development

Unlock the full course today

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

Fetching data in the app

Fetching data in the app - iOS Tutorial

From the course: Shared Economy for iOS Development

Start my 1-month free trial

Fetching data in the app

- [Tutor] As we have our app now, whenever a user signs in its going to create a row in that table. So new users get a row in that table and then, we want to be able to also list the rows from that table so that we can see who can mow more yard. So we need to be able to fetch the data. So let's write a function down at the bottom, so on line 46 I'm going to create a function called fetchUsers, and no parameters, open close curly braces. And we want to call this if the user is already signed in, so in our else from line 39, I'm going to call, self, fetchUsers and comment out the log out. And then also, if we have our app sync, perform successfully creating our row in the table, we'll call it as well. So, self, fetchUsers. So whether it's a new user logging in or an existing user, we want to fetch the users. So we're going to be able to use our API.swift classes to create a query to fetch the user. So I'm going to say on line 49, let q equal, and I know I want to list the app users, so…

Contents