From the course: iOS and watchOS App Development: Notifications

Unlock the full course today

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

Use buttons for actions

Use buttons for actions

From the course: iOS and watchOS App Development: Notifications

Start my 1-month free trial

Use buttons for actions

- [Instructor] Okay, with our IB actions now in the code, we can go ahead and start putting together buttons and the first button we're going to do is a toggle on the like button to go on like and unlike again. And we'll also do that reflecting it a little bit in the action. So what we're going to do here is first I'm going to just get the like button started, and we're just going to do an if sender.titleLabel, and I'm going to put a question mark here 'cause it tends to get really cranky on me, and text equals like, in that case we're going to set the sender.setTitle, and the title will change to unlike for UI control state normal, and I'ma just do if it isn't that, we'll move it back to like. So I'm just going to do a Cmd + Copy here, Cmd + C, Cmd + V, and turn that to like. So that's the simplest thing that we can do, but I'd like to also have this reflect in my actions. So I can change my actions here too, from the button, and so what we're going to do is do an…

Contents