Understanding Declared Properties
Although properties and instance variable access and accessors are often mashed together in the minds of programmers, I want to make sure that you understand the unique nature of properties and how they really work.
Whereas methods are concerned with sending messages to objects to get things done, properties are concerned with the state of the objects. Frameworks and other objects behave based on what they find in their properties (hence you can modify object behavior by changing a property); for example, a button’s background image is a property you set (indirectly, in Interface Builder) in Chapter 5.
You also may want to know something about the state of the object, such as its color, or about a window’s Root view controller.
In Chapter 12, I discuss creating a model object —
Trip. Your app’s view controllers, which act as a bridge between the views and the model, need to be able to find the
Trip object to get data and send it updates. All of this is done using properties.
As I discuss when creating an outlet in Chapter 9, a property looks like the following:
@property (strong, nonatomic) IBOutlet UIImageView *car;
But not all properties are outlets. If you select the
RTAppDelegate.h file in the Project inspector, you can see that it includes a
@property (strong, nonatomic) UIWindow *window;
And in Chapter 11, you add a
trip property to
@property (nonatomic, strong) Trip *trip;