FREELessons: 19Length: 2.3 hours

• Overview
• Transcript

# 3.7 Update the Reminder Interface Data

Now that we can successfully transition between screens, we need to be able to show the end user some detailed information about a Reminder.

## 5.Conclusion1 lesson, 00:38

### 3.7 Update the Reminder Interface Data

The first thing that I'd like to do as we start to build out the logic of our reminder interface controller is to know when we have an active reminder set. And then also set the initial stage so we can kinda build out what our interface is actually going to look like. So the first thing that I want to do is I want to start to work with this active reminder. So now when this active reminder gets set, what I'd like to be able to do is use our didSet again, so that we know when this has been set. And let's take care of a couple of things on our interface, namely the reminderNameLabel and the reminderDurationLabel. So just as we did before, let's go ahead and do a guard let. And we're gonna say that the reminder is going to be equal to the active reminder, which means we are going to attempt to get the value that was set here, and we want to be able to know whether or not that worked. And if it didn't work, then we're just gonna return. Let's not set anything. But if it did work, then we're gonna say, we want to use our reminder name label, set text function again. So we can say, reminder.name, and then we can also do our reminder duration label, set text method to use reminder.duration. So now we're able to set those two things and we want to also know if we have something or some sort of collection of stages in there because we can't assume that we're gonna have stages. But at this point, we wanna know if there is a stage and we want to set that as maybe that first stage as being the active stage. So, if we're going to do that, then we need a couple more properties. So let's go ahead and create another property here, this is going to be the activestage property, which is going to be very similar to what we did before, and we're also going to have a didset here as well. And one thing that we're also gonna wanna keep track of are a couple of different properties. The first one is going to be the active stage index. So we wanna know where we are in the current list of stages. So we're gonna say var activeStageIndex, and we're just gonna default that to 0. We're gonna say by default, it's always gonna be equal to 0. So now, once we have gotten this far, we're going to check to see that if we have any stages, and if we are not outside of the stage index, then we're gonna go ahead and start to set a couple of properties here. So we can say if reminder.stages.count is greater than or equal to our active stage index, which is by default 0. So we're saying, if there are more stages than our active index, then we can go ahead and let our stage be equal to, let's just grab the first one. So we'll say reminder.stages [activeStageIndex]. And in this case, we can say activeStage is gonna be equal to stage, just like that. So just by the sheer fact that we're setting this active stage, we can now do something similar up here to what we just did. So we'll do another guard let, we'll say stage = activeStage. And if that didn't work, then we'll just return. But if it did work, let's go ahead and set those properties in a similar fashion. So we'll say Stage, name, label.set text will be stage.name. So we're gonna leave it at that for now. We're not going mess around with the title. I'm gonna show you a new little nifty thing that we're gonna do for the timer. We're going to have a countdown timer. But we're gonna start to introduce that in another lesson. So let's go ahead and save this for now. Then let's go ahead and run our application. And we should be able to get to a point now where we can select a row from our table and then show some detailed information on it in our next view controller. So let's select morning wakeup. And as you can see now, at the top, here, I have morning wakeup. And I have the amount of time, it's a minute and 20 seconds. And then you can also see the current stage has been set to stretch. We haven't done anything with stage duration just yet. But so now I can see what information is associated with my morning wakeup, at least, to an extent. I can cancel out of this, and I can also go see the evening wind-down, and it's gonna build that interface out the same way. So we're starting to get a little bit closer, we're starting to select which is gonna be the active reminder. And we can set, also, the initial stage that we're going to use for this application. So in the next lesson, we're gonna start building out some of the functionality that's going to allow us to create some stages, and also transition between certain states that are gonna be in between all of those stages.

Back to the top