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
From the course: iOS and watchOS App Development: Notifications
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
(Locked)
Get interactive with notifications1m 39s
-
(Locked)
Configure notification categories3m 47s
-
(Locked)
Add categories to notifications2m 19s
-
(Locked)
Add actions to categories4m 37s
-
(Locked)
Respond to action requests4m 13s
-
Code the action response2m 32s
-
(Locked)
Code the next action response4m 17s
-
(Locked)
Test actions1m 47s
-
(Locked)
Text response actions2m 50s
-
(Locked)
Text response requests4m 13s
-
(Locked)
-
-
-
-
-
-
-