From the course: Code Clinic: Swift

Unlock the full course today

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

Query the data

Query the data - Swift Tutorial

From the course: Code Clinic: Swift

Start my 1-month free trial

Query the data

- [Narrator] Now that we've established a connection to our database, let's look at querying the database for the appropriate date. Remember, in our storyboard, we have a date picker that has the start date and the end date. So both of those should be selected when the user presses the update button to display the information in the bottom labels. Let's go back to view controller dot swift, and look at how to handle that. So near the bottom load realm method, right below where we initialize the realm, I'm going to call update days. We also have that method called inside of did press update. So now, we'll handle the update days method. What we want to do is take our dates for the start date and the end date, and query our database, selecting all of the entries that have dates within that range. So step one is to get the start and end dates, so let D one equals start picker dot date, and the same for the end picker's date. So we have D two and that's the end picker's date. Then we'll…

Contents