O'Reilly logo

Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming by Erica Sadun, Rod Strougo, Maurice Sharp

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding Previous and Next Car Buttons

You have given the user a way to create cars, and the app shows users car detail. But at the moment, you are always showing the same car. Now it is time to let the user choose which car to view. iOS has lots of ways to do this, and in Chapter 8, “Table Views I: The Basics,” you learn to use one of the most common ones. For now, you use Previous and Next buttons to switch cars.

Previous and Next car buttons work by changing the index of the current car, displayedCarIndex, to a new element in the arrayOfCars. Then they update the displayed info with the routine you wrote earlier. The only real difference between the buttons is that Previous subtracts 1 from the current index, and Next adds 1. Instead of writing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required