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

Properties

Properties let you define instance variables and let the compiler take care of creating the accessor methods—that is, methods that access (get or set) variables or information. The compiler also generates the underscore version of the variable. Declaring a property is simple:

@property float fuelAmount;

This tells the compiler to create one instance variable and two methods:

float _fuelAmount; - (float)fuelAmount; - (void)setFuelAmount:(float)fuelAmount;

You might have noticed that the variable and method declarations are identical to the ones in Listing 2-3.

The compiler generates the underscore version of the variable for you. Any non-car objects have to use the getter and setter. The variables and method ...

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