From the course: iOS and watchOS App Development: Notifications

Unlock the full course today

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

Code the next action response

Code the next action response

From the course: iOS and watchOS App Development: Notifications

Start my 1-month free trial

Code the next action response

- [Instructor] The third action is the next step button, which changes the content of a notification. So we're going to make similar code to the one we did for the next step button that we did earlier. So I'm going to go down here, and the first thing I'm going to do is I'm going to get the step, which I'm going to use a guard for, since I have a whole bunch of things I've got to unwrap here, so guard var step equals content dot userInfo, step as an integer, and if not, return. And now that I have step, I can increment it by one, and check if it's above the pizza steps count. So I'll do if, step is less than pizzaSteps dot count, which means that we're in range of the array, and if not, I'm going to change the content, dot body, into pizzaSteps. Bracket, step. I'm also going to have to change the user info, so I'm going to do content again, dot userInfo, and save my new step number. That will equal step. So we're going to put in the request, which is pretty much the same as we did…

Contents