Creating and Printing Cars

You now have a Car class in your CarValet project, but it is not called or used anywhere in your app. Open up the ViewController.m implementation file and follow these steps:

1. Add the #import "Car.h" statement below the last import at the top of the ViewController.m file.

2. Add the viewWillAppear: method in Listing 2-8 below the viewDidLoad method.

Listing 2-8 ViewController.m viewWillAppear: Method

- (void)viewWillAppear:(BOOL)animated {     [super viewWillAppear:animated];     Car *myCar = [[Car alloc] init];                        // 1     [myCar printCarInfo];                                   // 2     myCar.make = @"Ford";                                   // 3     myCar.model ...

Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.